ASP.NET 身份验证 - 多应用程序和多用户数据库
我们有一个简单的 ASP.NET 应用程序,它使用 ASP.NET SqlMembershipProvider,一切都很棒。
我们希望在同一服务器上创建第二个应用程序,也使用 SqlMembershipProvider,但使用不同的“applicationName”,以便两个应用程序之间的用户帐户保持独立。
看起来这可以通过创建两个不同的应用程序域(即它们每个都有自己的 web.config)来实现,但我希望将它们放在不同的目录中,这样我就没有 3 个 web.config(一个对于每个应用程序以及主要应用程序),所有应用程序都必须保持同步。所以我追求的是:
/web.config
/APP1 (uses membership provider in /web.config, with userlist A)
/APP2 (uses membership provider in /web.config, with userlist B)
定义使用不同“applicationName”值的多个成员资格提供程序看起来很简单。
但是如何告诉 system.web.authentication 节点使用哪个成员资格提供程序?
据我所知,它将始终使用默认值。
We have a simple ASP.NET app that uses the ASP.NET SqlMembershipProvider and all is great.
We want to create a second app on the same server, also use the SqlMembershipProvider, but a different "applicationName" so that the user accounts between the two apps are kept separate.
It looks like this would be possible by making the two different app domains (ie they each have their own web.config), but I'm hoping to just put them in different directories so I don't have 3 web.configs (one for each app, and the main one) that all have to be kept synchronized. So what I'm after is:
/web.config
/APP1 (uses membership provider in /web.config, with userlist A)
/APP2 (uses membership provider in /web.config, with userlist B)
It looks simple to define multiple membership providers that use a different 'applicationName' value.
But how do you tell the system.web.authentication node which membership provider to use?
As far as I can figure, it will always use the default.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确地阅读了您的场景,听起来这两个应用程序之间的唯一区别是“ApplicationName”属性。
因此,如果您在两个应用程序的 Application_Start(在 Global.asax 中)中进行设置,那么您应该会很顺利。
If I read your scenario correctly, it sounds like the only difference between the two applications is the "ApplicationName" property.
So, if you set that in the Application_Start (in Global.asax) of each of the two apps, you should be golden.
使用您的结构,我认为您必须围绕会员提供程序实现您自己的包装器,有效地创建您自己的提供程序,该提供程序仅填充请求并根据应用程序目录修改应用程序名称值。
Using your structure I think you'd have to implement your own wrapper around the Membership provider, effectively creating your own provider that just shims the requests and modifies the appname value based on the apps directory.