如何部署 ASP.net 自定义 MembershipProvider?
我编写了一个自定义 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看应用程序的 web.config 文件,您应该有一个名为 system.web 的部分。 其中有一个包含提供者列表的成员资格元素。 您应该能够添加您的提供商并在那里设置默认提供商。 一旦您的成员资格提供程序以这种方式注册,您应该也能够从 IIS 选择它作为该应用程序的默认提供程序。
providers 元素允许您注册多个提供商以供选择。 另一个功能是您可以清除在计算机上的其他配置文件中注册的成员资格提供程序。 这可以减少以后配置应用程序时出错的可能性。 为此,请添加列表中第一个成员资格提供者(元素)之前的元素。
如果您想仅使用 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.
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.
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.