Home
 Index > ASP.NET Web Applications > Copying a Web Application results in a new Appl...

ASP.NET Web Applications:  Security , Profile Provider , Profile

Copying a Web Application results in a new ApplicationId in the ASPNETDB and users are unable to log on.

When an Application is copied to a different Server or different directory on the same server, all user memberships and roles are invisible to the application though the records remain in the database and there is no error connecting to the database.

Added on 4 Jul 2008

Scenarios:

Scenario Summary:
New applicationNames are created when the Web Application is copied.
Scenario Details:

The new path causes the application to assume a new applicationName and, in effect, create a new application in the ASPNETDB database.  When a user attempts to log on, the application looks up the user’s credentials for that application.  Since this is “seen” as a new application, none of the existing users are recognized (i.e., the existing user records in the database are associated with what is “seen” as a different application).

Added on 4 Jul 2008

Solution Summary:
To resolve this issue, specify the applicationName for membership and all providers in the Web.config file to ensure it remains consistent when copying it to different servers or directories.
Solution Details:

Example Web.config:

 

          <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="20">
               <
providers>
                    <
remove name="SqlProvider" />
                    <
add name="SqlProvider" applicationName="MyAppName" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="connString" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Encrypted" maxInvalidPasswordAttempts="6" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
               </
providers>
          </
membership>
          <!--
   applicationName="Organizer" -->
          <
roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
               <
providers>
                    <
remove name="CustomizedRoleProvider" />
                    <
add name="CustomizedRoleProvider" applicationName="MyAppName" type="System.Web.Security.SqlRoleProvider" connectionStringName="connString" />
               </
providers>
          </
roleManager>
         
<profile defaultProvider="TableProfileProvider" automaticSaveEnabled="false" enabled="true" inherits="KitchenHelper.ProfileUtility.UserProfile">
                 <
providers>
                        <
clear />
                        <
add name="TableProfileProvider" type="SqlTableProfileProvider" applicationName="MyAppName" connectionStringName="connString" table="app_UserProfile" />
                        <
add name="ViewProfileProvider" type="SqlTableProfileProvider" applicationName="MyAppName" connectionStringName="connString" table="vw_app_UserProfile" />
                        <
add name="StoredProcedureProfileProvider" applicationName="MyAppName" type="SqlStoredProcedureProfileProvider" connectionStringName="connString" setProcedure="app_setCustomProfileData" readProcedure="app_getCustomProfileData" />
                 </
providers>
          </
profile>
Was this solution useful? Yes No Added on 4 Jul 2008
Rating: 

Copyright 2010 © E-Centric, Inc. | Terms of Use