We have a simple ASP.NET app tha开发者_如何学运维t 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.
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.
protected void Application_Start(object sender, EventArgs e)
{
Membership.Provider.ApplicationName = "test";
}
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.
精彩评论