Use the custom provider in ASP. NET2.0 correctly

Source: Internet
Author: User

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:

 
 
  1. < membership>   
  2. < providers>   
  3. < 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="" />   
  4. < /providers>   
  5. < /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:

 
 
  1. < connectionStrings>  
  2.     < add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />  
  3.   < /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.

 
 
  1. < connectionStrings>  
  2. < add name="MySqlProviderConnection" connectionString="server=localhost;integrated security = true;Initial Catalog=aspnetdb" />  
  3. < /connectionStrings>   
  4.  
  5. < system.web>  
  6. < membership defaultProvider="MySqlMembershipProvider">  
  7. < providers>  
  8. < add connectionStringName="MySqlProviderConnection" name="MySqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />  
  9. < /providers>  
  10. < /membership>  
  11. < /system.web>  
  12.  

Other providers such as profile and role have the same modification method. This is the custom provider method in asp. net2.0.

  1. Application of session storage mode in ASP. NET
  2. Set of methods for uploading and downloading files in ASP. NET
  3. Introduction to cookie read/write methods in ASP. NET
  4. Javascript operations in ASP. NET
  5. Introduction and implementation of Single Sign-On in ASP. NET2.0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.