Membership, Roles, or Profile features are used to develop an ASP. NET2.0 application locally. You have created some new ASP. NET users, and everything is fine.
Copy the program to the remote server) or just move it to another directory on your local server) and run the program. For some reason, although we can connect to the Membership database, an error will occur when we log in. It does not throw a connection error), but prompts you with a similar error: "failed to log on. please try again" Login attempt unsuccessful, please try again)
Cause:
This common error occurs because Membership, roles, and profile providers have been added to the web. config of the program. However, applicationName attribute is not specified. Suppose that the bold Section of the following code exists)
- <membership>
- <providers>
- <clear/>
- <add name="AspNetSqlMembershipProvider"
- type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
- connectionStringName="LocalSqlServer"
- enablePasswordRetrieval="false"
- enablePasswordReset="true"
- requiresQuestionAndAnswer="true"
- requiresUniqueEmail="false"
- passwordFormat="Hashed"
- maxInvalidPasswordAttempts="5"
- minRequiredPasswordLength="7"
- minRequiredNonalphanumericCharacters="1"
- passwordAttemptWindow="10"
- passwordStrengthRegularExpression=""
- applicationName="/"
- />
- </providers>
- </membership>
If it is copied to another place or server and replaced with a virtual path such as "/app1" or, when Membership APIs is used, they "cannot see" existing users in the database-because they will use a different applicationName to search for users in the database, filter users in the application_Users table accordingly. This is why the above error occurs.
How to solve this problem:
The simplest way is to open the aspnet_Users and aspnet_Application tables in the ASPNETDB database and "Recall" figure out, because we may have forgotten the name of our virtual directory at that time) the program name used to create users and other data is searched in the aspnet_Application table)
Then open your web. in the config file, add an applicationName attribute to the place where the provider declares and assign values to it. For example, the following code sets it to/website8 in the aspnet_Application table:
- <membership>
- <providers>
- <clear/>
- <add name="AspNetSqlMembershipProvider"
- type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
- connectionStringName="LocalSqlServer"
- enablePasswordRetrieval="false"
- enablePasswordReset="true"
- requiresQuestionAndAnswer="true"
- requiresUniqueEmail="false"
- passwordFormat="Hashed"
- maxInvalidPasswordAttempts="5"
- minRequiredPasswordLength="7"
- minRequiredNonalphanumericCharacters="1"
- passwordAttemptWindow="10"
- passwordStrengthRegularExpression=""
- applicationName="/website8"
- />
- </providers>
- </membership>
The above describes ASP. NET's Membership
- ASP. NET TypeConverter
- Analysis on TypeResolver of ASP. NET
- Define JavaScriptConverter in ASP. NET
- How to replace Sys. Services in ASP. NET
- Use Profile Service of ASP. NET AJAX