Setting ApplicationName in ASP.NET 2.0 Web Apps
We'd noticed that our latest web app was creating two records in the aspnet_Application table, which was causing new users to be created twice, once for each applicationID. Obviously this isn't what we wanted, and the behavior started to create some mismatches between our data as records began to appear for the multiple IDs.
The solution was that we were not explicitly setting the applicationName property for each provider used. The machine.config file specifies that any provider whose applicationName is not set will default to the directory path, such as "/ClarityApp". Once we realized that our RoleManager provider was missing the property, I cleaned out the records and once again added my Roles and Users using the ASP.NET Configuration portal site, and presto, only one application record is created, with all providers referencing this applicationName.
I changed the applicationName to match across the providers, but you can also use separate app names in order to host multiple User/Roles sets within a database...you'd just need to include the current ApplicationID as a parameter in all of your stored procedures.
Here's a portion of our web.config:
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
<providers >
<clear/>
<add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ManagerConnection"
applicationName="Clarity Test"
enablePasswordRetrieval="true"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="2"
passwordFormat="Encrypted"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider" applicationName="Clarity Test" type="System.Web.Security.SqlRoleProvider" connectionStringName="ManagerConnection"/>
</providers>
</roleManager>