NET Membership Login Verification Summary

Source: Internet
Author: User

Asp. NET provides a set of membership validators.

Use when used in practice

System.Web.Security is the life gate space where

In an ASP. NET application, the membership class is used to validate user credentials and manage user settings, such as passwords and e-mail addresses. The membership class can be used alone or 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.

The Membership class provides functionality that can be used to:
1) Create a new user.
2) Store membership information (user name, password, e-mail address, and support data) in Microsoft SQL Server or other similar data stores.
3) Authenticate the user who is accessing the site. Users can be authenticated programmatically, or you can use the Login control to create a complete authentication system that requires little or no code.
4) Manage Passwords. This includes creating, changing, retrieving, and resetting passwords, and more. You can choose to 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.

The Web. config is also to be modified. Add the authentication node under the system.web node.

Membership since it is used for membership management, of course, login authentication is required, so first add a forms validation.

<authentication mode= "Forms" >
<forms loginurl= "Login.aspx" name= ". Aspxlogin"/>
</authentication>

Also add membership nodes under the system.web node.

<membership defaultprovider= "AspNetSqlMembershipProvider" userisonlinetimewindow= "hashAlgorithmType=" ">
<providers>
<clear/>
<add connectionstringname= "ConnectionString" enablepasswordretrieval= "false" enablepasswordreset= "true" Requiresquestionandanswer= "true" applicationname= "/" requiresuniqueemail= "false" passwordformat= "Hashed" maxinvalidpasswordattempts= "5" minrequiredpasswordlength= "7" minrequirednonalphanumericcharacters= "1" passwordattemptwindow= "passwordstrengthregularexpression=" "Name=" AspNetSqlMembershipProvider "type=" System.Web.Security.SqlMembershipProvider, system.web, version=2.0.0.0, Culture=neutral, publickeytoken= b03f5f7f11d50a3a "/>
</providers>
</membership>

Property Explanation Description:

defaultprovider: The name of the provider. The default is AspNetSqlMembershipProvider. If you have more than one provider, it's wise to specify a default value
Userisonlinetimewindow: Specifies the number of minutes that a user is considered online after the date/time stamp of the most recent activity.
Hashalgorithmtype: The identifier of the algorithm used to hash the password, or null to use the default hashing algorithm.connectionStringName: The connection name of the membership database.
enablePasswordRetrieval: Indicates whether the current membership provider is configured to allow users to retrieve their passwords.
enablePasswordReset: Indicates whether the current membership provider is configured to allow users to reset their passwords.
requiresQuestionAndAnswer: Indicates whether the default membership provider requires users to answer a password question when password reset and retrieval occurs.
ApplicationName: The name of the application.
requiresUniqueEmail: Indicates whether the membership provider is configured to require a unique e-mail address for each user name.
Passwordformat: Indicates the format in which the password is stored in the membership data store. The values are optional clear, Encrypted, and Hashed. The clear password is stored in clear text, which improves the performance of storing and retrieving passwords, but is less secure and can be easily read when data source security is compromised. The Encrypted password is encrypted when it is stored and can be decrypted when the password is compared or retrieved. Such passwords require additional processing when stored and retrieved, but are more secure and are not easily accessible when the security of the data source is compromised. The Hashed password is hashed using a one-way hashing algorithm and a randomly generated salt value when it is stored in the database. When a password is validated, the password is hashed for validation with a salt value in the database. The hash password could not be retrieved.
maxinvalidpasswordattempts: The number of invalid password or invalid password answer attempts that were allowed before the membership user was locked out.
minRequiredPasswordLength: The minimum length required by the password.
minRequiredNonalphanumericCharacters: The minimum number of special characters that must be included in a valid password.
passwordAttemptWindow: The number of minutes that the maximum number of invalid or invalid password answer attempts is allowed before the membership user is locked out. This is an extra measure to prevent an unknown source from repeatedly trying to guess the answer to a password or password question for a membership user.
passwordstrengthregularexpression: The regular expression that calculates the password.

After you configure Web. config for membership, then configure its role management rolemanager, also under system.web.

<rolemanager enabled= "true" cacherolesincookie= "true" >
<providers>
<clear/>
<add connectionstringname= "ConnectionString" applicationname= "/" Name= "AspNetSqlRoleProvider" type= " System.Web.Security.SqlRoleProvider, system.web, version=2.0.0.0, Culture=neutral, publickeytoken=b03f5f7f11d50a3a "/>
</providers>
</roleManager>

Property Explanation Description:
cacheRolesInCookie: Indicates whether the role of the current user is cached in a Cookie.
When the cacheRolesInCookie property is set to True in the configuration file, the role information for each user is stored in a Cookie on the client. When a role management check determines whether a user belongs to a particular role, the role Cookie is checked before the calling role provider checks the list of roles in the data source. The Cookie is dynamically updated on the client to cache the most recently verified role name.
The Web. config is almost configured.

1th page Membership role and Rights management [1]
2nd page Membership role and Rights management [2]
3rd page Membership role and Rights management [3]
4th page Membership role and Rights management [4]
5th page Membership role and Rights management [5]
6th page Membership role and Rights management [6]

NET Membership Login Verification Summary

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.