Search code examples
c#asp.netasp.net-membershipmembership-provider

ASP.NET membership provider generates two applications in the database


I am using the below defined membership provider web config settings. when I access my admin pages to start to add roles and users to the system generated SQL Server tables I see two applications created. one with a application name of "/" and the second is called what my setting is configured to PolyWebSite.

My steps are:

  1. as an unauthenticated user I browse to role config page to add admin and other roles. this is when the first application is created.

  2. I browse to a custom user page where I add users and assign them roles. also as an unauthenticated user. this is when a second application is created with the name PolyWebSite as set in my web.config

    <roleManager enabled="true" />
    <membership defaultProvider="AspNetSql2005MembershipProvider">
        <providers>
            <add name="AspNetSql2005MembershipProvider" 
                 type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0" 
                 connectionStringName="SqlConnString" 
                 enablePasswordReset="true" 
                 requiresQuestionAndAnswer="true" 
                 applicationName="PolyWebSite" 
                 requiresUniqueEmail="false" 
                 maxInvalidPasswordAttempts="5" 
                 minRequiredPasswordLength="1" 
                 minRequiredNonalphanumericCharacters="0" 
                 passwordAttemptWindow="10" 
                 passwordStrengthRegularExpression=""
                 passwordFormat="Clear"/>
        </providers>
    </membership>
    

Solution

  • figured it out: added details to the roleManager part of the web.config to be in sync with membership section. items added were connectionStringName and applicationName.

       <membership defaultProvider="AspNetSql2005MembershipProvider">
          <providers>
            <add name="AspNetSql2005MembershipProvider" 
                 type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
                 connectionStringName="SqlConnString" 
                 enablePasswordReset="true" 
                 requiresQuestionAndAnswer="true" 
                 applicationName="PolyWebSite" 
                 requiresUniqueEmail="true" 
                 maxInvalidPasswordAttempts="5" 
                 minRequiredPasswordLength="1" 
                 minRequiredNonalphanumericCharacters="0" 
                 passwordAttemptWindow="10" 
                 passwordStrengthRegularExpression=""
                 passwordFormat="Clear"/>
          </providers>
        </membership>
    
    
        <roleManager enabled ="true" defaultProvider ="SqlRoleProvider" >
          <providers>
            <add name ="SqlRoleProvider"
              type="System.Web.Security.SqlRoleProvider"
              connectionStringName="SqlConnString"
              applicationName="PolyWebSite"/>
          </providers>
        </roleManager>