如何部署 ASP.net 自定义 MembershipProvider?

发布于 2024-07-11 13:57:58 字数 346 浏览 5 评论 0原文

我编写了一个自定义 MembershipProvider,它使用自定义数据库架构来存储成员,但我在弄清楚如何部署该提供程序时遇到了困难。 我的目标服务器正在运行 IIS7,并且我能够导航到用于添加 .NET 用户提供程序的对话框,但不允许我选择包含提供程序和用户提供程序的程序集。 然后是课程,它提供了一个包含几个 MS 编写的提供程序的下拉菜单。

我是否需要将程序集放在特定位置以便 IIS 发现我的 MembershipProvider 类? 如果是这样,.dll 需要去哪里? 否则,如何告诉 ASP.Net 使用我的 MembershipProvider? 我见过的每个示例都只是引用完全限定的类名,但没有提及需要如何部署该文件。

I've written a custom MembershipProvider that uses a custom database schema for storing the members, but I am having trouble figuring out how to deploy the provider. My target server is running IIS7, and I am able to navigate to a dialog for a adding a .NET User Provider, but instead of allowing me to select the assembly containing the provider & then the class, it provides a drop-down with a couple of MS written providers.

Do I need to drop my assembly in a specific location so that my MembershipProvider class is discovered by IIS? If so, what where does the .dll need to go? Otherwise, how do tell ASP.Net to use my MembershipProvider? Every example I've seen simply references the fully qualified class name, but makes no mention of how the file needs to be deployed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梅倚清风 2024-07-18 13:57:58

如果您查看应用程序的 web.config 文件,您应该有一个名为 system.web 的部分。 其中有一个包含提供者列表的成员资格元素。 您应该能够添加您的提供商并在那里设置默认提供商。 一旦您的成员资格提供程序以这种方式注册,您应该也能够从 IIS 选择它作为该应用程序的默认提供程序。

<system.web>
    ...
    <membership defaultProvider="MyMembershipProvider" 
                    userIsOnlineTimeWindow="15">
        <providers>
            <add name="MyMembershipProvider"
                             type="Common.Auth.MyMembershipProvider, Common" 
                             connectionStringName="MyAuthDBConnectionString" 
                             enablePasswordRetrieval="true" 
                             enablePasswordReset="true" 
                             requiresQuestionAndAnswer="true" 
                             writeExceptionsToEventLog="false" />
        </providers>
    </membership>
    ...
</system.web>

providers 元素允许您注册多个提供商以供选择。 另一个功能是您可以清除在计算机上的其他配置文件中注册的成员资格提供程序。 这可以减少以后配置应用程序时出错的可能性。 为此,请添加列表中第一个成员资格提供者(元素)之前的元素。

<system.web>
    ...
    <membership defaultProvider="MembershipProvider1">
        <providers>
            <clear />
            <add name="MembershipProvider1" ... />
            <add name="MembershipProvider2" ... />
        </providers>
    </membership>
    ...
</system.web>

如果您想仅使用 IIS 管理器向多个 Web 应用程序注册同一提供程序,则需要将程序集放入 GAC 中,并将提供程序添加到计算机配置文件之一。 当部署单个应用程序时,这通常是更多的工作却没有什么好处。

If you look in the web.config file for your application, you should have a section called system.web. Within that there is a membership element with a list of providers. You should be able to add your provider and set a default provider there. Once your membership provider is registered in this way, you should be able to select it as a default for that application from IIS as well.

<system.web>
    ...
    <membership defaultProvider="MyMembershipProvider" 
                    userIsOnlineTimeWindow="15">
        <providers>
            <add name="MyMembershipProvider"
                             type="Common.Auth.MyMembershipProvider, Common" 
                             connectionStringName="MyAuthDBConnectionString" 
                             enablePasswordRetrieval="true" 
                             enablePasswordReset="true" 
                             requiresQuestionAndAnswer="true" 
                             writeExceptionsToEventLog="false" />
        </providers>
    </membership>
    ...
</system.web>

The providers element allows you to register multiple providers to choose from. Another feature is that you can clear out membership providers registered in other configuration files on the machine. This can make configuring your application less error prone later on. To do so, add the <clear/> element before the first membership provider (the <add/> element) in the list.

<system.web>
    ...
    <membership defaultProvider="MembershipProvider1">
        <providers>
            <clear />
            <add name="MembershipProvider1" ... />
            <add name="MembershipProvider2" ... />
        </providers>
    </membership>
    ...
</system.web>

If you want to register the same provider with multiple web applications just using IIS Manager, you will need to put the assembly in the GAC and add the provider to one of the machine config files instead. This is usually more work for little benefit when deploying a single application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文