On the MSDN page for the Membership.ApplicationName
property (which applies to an asp.net membership provider), it warns that although one can change Membership.ApplicationName
in code, 'The ApplicationName property is not thread safe for multiple writes, and changing the ApplicationName property value can result in unexpected behavior for multiple users of an application.' They therefore recommend avoiding using it for a 'web application'.
This is because the default SqlMembershipProvider
is written as a singleton. But here's my question: is it OK if all the threads in my application process are going to set Membership.ApplicationName
to the same thing?
I'm thinking of having multiple applications on my IIS box, each with their own separate application pool. I want to point them to the same location, but based on the hostname, set the application provider to different things. Wouldn't this actually be OK? It might not be a thread-safe operation, but doesn't each application pool have its own process and therefore its own instance of SqlMembershipProvider
? So, every thread that tried to set Membership.ApplicationName
for a given SqlMembershipProvider
instance would be trying to set it to the same thing (the provider that is appropriate for that hostname). Or am I missing something?
I guess the main question is, do ALL asp.net applications share one SqlMembershipProvider
, or is a separate one created for each application pool process?