JavaScript Editor jscript editor     Web designer 

Main Page

ASP.NET Membership is configured using the membership element in the Web.config file for your application. The membership element is a sub-element of the system.web section. You can enable ASP.NET Membership for an application by directly editing the Web.config file for that application, or you can use the Web Site Administration Tool, which provides a wizard-based interface. As part of membership configuration, you specify:

For an example of configuring ASP.NET Membership using the Web Site Administration Tool, see Walkthrough: Creating a Web Site with Membership and User Login (Visual Studio).

Specifying the Default Provider

You specify the default membership provider using the defaultProvider attribute of the membership element. The machine configuration specifies a SqlMembershipProvider instance named "AspNetSqlMembershipProvider" that is identified as the default provider if you do not specify a default provider explicitly. The "AspNetSqlMembershipProvider" connects to the aspnetdb database in the local SQL Server.


You need to set up the database used by the SqlMembershipProvider before using it in an application. For details, see Creating and Configuring the Application Services Database for SQL Server.

You can also specify the default provider instance and options for that provider by configuring a provider in the membership section. You use the providers element to identify a provider to add to the collection of providers available for the application. You can identify your provider instance as the default provider by using the value of the name attribute as the defaultProvider value. When you specify a provider instance, you must also specify a valid connection string for that instance by using the connectionStrings section of the configuration. For example, the following Web.config file identifies a SqlMembershipProvider instance that connects to a SQL Server other than the local server.

В CopyCode imageCopy Code
    <add name="MySqlConnection" connectionString="Data 
      Source=MySqlServer;Initial Catalog=aspnetdb;Integrated
      Security=SSPI;" />
    <authentication mode="Forms" >
      <forms loginUrl="login.aspx"
        name=".ASPXFORMSAUTH" />
      <deny users="?" />
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
        <clear />
          passwordFormat="Hashed" />

See Also

Other Resources

Managing Users by Using Membership
ASP.NET Web Site Security (Visual Studio)

JavaScript Editor jscript editor     Web designer