In asp.net 2.0, various providers are provided, including membership, role, and profile. You can use a custom provider to conveniently Manage Roles, users, and so on, without having to write your own code. In vs.net 2005, all types of providers use SQL express by default. What should I do if I want to use SQL sever 2000 or SQL server 2005? The following is an example:
To customize the provider correctly, we need to go to C: \ WINNT \ Microsoft. NET \ Framework \ v2.0.50215, run a tool named aspnet_regsql, and then set it according to the steps. Finally, a database named aspnetdb will be generated.
Go to C: \ WINNT \ Microsoft. NET \ Framework \ v2.0.50215 \ config, open the machine. config file, and find the following code:
- < membership>
- < providers>
- < 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" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
- < /providers>
- < /membership>
Note: Some attributes of the membership provider are defined here, such as requirements for Password Input and registration prompts. Pay attention to connectionStringName = "LoacalSqlserver, search for localsqlserver and find the following code:
- < connectionStrings>
- < add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
- < /connectionStrings>
You can see it. If you want to change it to your SQL server 2000 or SQL server 2005, you can change it here.
Or you can change it in web. config.
- < connectionStrings>
- < add name="MySqlProviderConnection" connectionString="server=localhost;integrated security = true;Initial Catalog=aspnetdb" />
- < /connectionStrings>
-
- < system.web>
- < membership defaultProvider="MySqlMembershipProvider">
- < providers>
- < add connectionStringName="MySqlProviderConnection" name="MySqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- < /providers>
- < /membership>
- < /system.web>
-
Other providers such as profile and role have the same modification method. This is the custom provider method in asp. net2.0.
- Application of session storage mode in ASP. NET
- Set of methods for uploading and downloading files in ASP. NET
- Introduction to cookie read/write methods in ASP. NET
- Javascript operations in ASP. NET
- Introduction and implementation of Single Sign-On in ASP. NET2.0