System.Web.Security.SqlMembershipProvider Class

Manages storage of membership information for an ASP.NET application in a SQL Server database.

See Also: SqlMembershipProvider Members


public class SqlMembershipProvider : MembershipProvider


This class is used by the System.Web.Security.Membership and System.Web.Security.MembershipUser classes to provide membership services for an ASP.NET application using a SQL Server database. You cannot use a System.Web.Security.SqlMembershipProvider without SQL Server. When your computer has SQL Server Express installed with the default instance name and user-instancing enabled, the System.Web.Security.SqlMembershipProvider object will create a database called aspnetdb in the application's App_Data directory the first time the application is run.

To manually create the database, run the Aspnet_regsql.exe executable found in the %systemroot%\Microsoft.NET\Framework\ versionNumber folder and specify the -A m option (for example aspnet_regsql.exe -A m). The database created is called Aspnetdb. Alternatively, run Aspnet_regsql.exe to pull up the GUI configuration mode and choose to configure all ASP.NET Features.

If the membership provider is configured with a connection string that uses integrated security, the process account of the ASP.NET application must have rights to connect to the SQL Server database.

The Machine.config file defines a default System.Web.Security.SqlMembershipProvider instance named AspNetSqlMembershipProvider that connects to the default SQL Server Express instance on the local machine. You can use this instance of the provider if you installed SQL Server Express with the default instance name, or you can define your own instance in the Web.config file for your ASP.NET application.

If you set the passwordCompatMode attribute to System.Web.Configuration.MembershipPasswordCompatibilityMode.Framework40, the application can use the hashing and encryption membership options that were added in ASP.NET 4. However, if the passwordCompatMode attribute is set to System.Web.Configuration.MembershipPasswordCompatibilityMode.Framework20, only the hashing and encryption membership options from the ASP.NET 2.0, ASP.NET 3.5, and ASP.NET 3.5 SP1 can be used. The default value is System.Web.Configuration.MembershipPasswordCompatibilityMode.Framework20. For more information, see System.Web.Configuration.MembershipPasswordCompatibilityMode.


Namespace: System.Web.Security
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0