Initial knowledge asp.net membership user Management _ Basic Application

Source: Internet
Author: User
Tags microsoft sql server connectionstrings

One, with the session of the different points

Membership generally refers to the use of Microsoft's ASPNETDB database for identity authentication

Session refers to the conversation information of a site user

The functions provided by the membership class can be used to: 

1. Create a new user.

2. Store membership information (user name, password, e-mail address, and support data) in a Microsoft SQL Server or other similar data store.

3. Authenticate users who visit the Web site. You can authenticate users programmatically, or you can use the Login control to create a complete authentication system that requires little or no code.

4. Manage passwords, including creating, changing, retrieving, and resetting passwords, and so on. You can optionally configure ASP.net membership to require a password question and its answer to authenticate the password reset and retrieval requests of the user who has forgotten the password.

Although ASP.net membership is a stand-alone feature used in asp.net for authentication, it can be integrated with asp.net role management to provide authorization services to the site. Membership can also be integrated with the System.Web.Profile of ASP.net users to provide application-specific customization implementations that can be tailored for individual users. For more information, see Understanding Role Management and ASP.net profile properties Overview.

The Membership class relies on the membership provider to communicate with the data source. The. NET Framework includes a sqlmembershipprovider (storing user information in a Microsoft SQL Server database) and a ActiveDirectoryMembershipProvider (allows user information to be stored on Active Directory or Active Directory Application Mode (ADAM) servers). You can also implement a custom membership provider to communicate with other similar data sources that can be used by the membership class. The custom membership provider inherits the MembershipProvider abstract class. For more information, see Implementing a membership provider.

By default, ASP.net membership can support all ASP.net applications. The default membership provider is SqlMembershipProvider and specified in the Computer configuration by name AspNetSqlProvider. The default instance of SqlMembershipProvider is configured to connect to a local instance of Microsoft SQL Server.

You can specify the SqlMembershipProvider of a AspNetSqlProvider instance as the default provider by modifying the default settings, or specify an instance of the custom provider as asp.net using the web.config file The default provider for an application. You can use the Membership configuration section in the Web.config file to specify the asp.net membership configuration for your WEB application. You can use the providers section of the membership section to specify a membership provider other than one of the default providers. For example, the following membership section removes the default membership provider from the current application configuration and adds a new provider named SQLProvider that connects to an instance of SQL Server named MySQLServer.

Copy Code code as follows:

<configuration>
<connectionStrings>
<add name= "sqlservices" connectionstring= "Data source=mysqlserver;integrated security=sspi;initial Catalog= aspnetdb; "/>
</connectionStrings>
<system.web>
<membership defaultprovider= "SQLProvider" userisonlinetimewindow= ">"
<providers>
<remove name= "AspNetSqlProvider"/>
<add name= "SQLProvider" type= "System.Web.Security.SqlMembershipProvider" connectionstringname= "Sqlservices" Enablepasswordretrieval= ' false ' enablepasswordreset= ' true ' requiresquestionandanswer= ' true ' passwordformat= ' Hashed "applicationname="/"/>
</providers>
</membership>
</system.web>
</configuration>

In an ASP.net application, the Membership class is used to authenticate user credentials and manage user settings such as passwords and e-mail addresses. The membership class can be used alone or in conjunction with FormsAuthentication to create a complete user authentication system for a Web application or Web site. The Login control encapsulates the membership class, providing a convenient user authentication mechanism.

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.