How to Use the ASP. NET Login Control

Source: Internet
Author: User

There are many ASP. NET login controls, which encapsulate a series of functions for system login in most WEB applications, involving many aspects. Multiple ASP. NET Logon controls provide a reliable login solution for ASP. NET Web applications without programming. By default, the logon control is integrated with ASP. NET membership and Forms authentication to automate the user authentication process for the website. By default, the ASP. NET Logon control works on HTTP in plain text format. If you are very concerned about security, You Can Use HTTPS with SSL encryption.

Note:

If you change the Method of an ASP. NET webpage from the default value of POST to GET, the logon control may not work properly.

ASP. NET Login Control

The Login control displays the user interface used to perform user authentication. The Login control contains a text box for user names and passwords and a check box that allows users to indicate whether the server needs to use ASP.. NET membership stores their identity and automatically performs authentication when they access the site next time.

 

The Login control has attributes for custom display and custom messages, and links to other pages. On those pages, you can change the password or retrieve the forgot password. The Login control can be used as an independent control on the home page, or you can use it on a dedicated logon page.

If you use the Login control together with ASP. NET membership, you do not need to write the code to perform authentication. However, if you want to create your own authentication logic, you can process the Authenticate event of the Login control and add custom authentication code.

The LoginView control displays different information to anonymous users and logon users. This control displays one of the following two templates: AnonymousTemplate or LoggedInTemplate. In these templates, you can add tags and controls for anonymous users and authenticated users to display appropriate information respectively.

The LoginView control also contains ViewChanging and ViewChanged events. You can write the processing programs for these events when users log on and change the status.

The LoginStatus control displays the logon link for a user who has not passed the authentication and the Logout link for the user who has passed the authentication. The logon link takes the user to the logon page. The Logout link resets the identity of the current user to an anonymous user.

You can set the LoginText and LoginImageUrl attributes to customize the appearance of the LoginStatus control.

If you have logged on using ASP. NET membership, the LoginName control displays the user's logon name. Alternatively, if the site uses integrated Windows authentication, the control displays the user's Windows account name.

The PasswordRecovery control allows you to retrieve the User Password Based on the email address used when creating an account. The PasswordRecovery control sends an email containing the password to the user.

You can configure ASP. NET membership to store passwords with irreversible encryption. In this case, the PasswordRecovery control generates a new password instead of sending the original password to the user.

You can also configure membership to include a security prompt that the user must answer in order to retrieve the password. In this case, the PasswordRecovery control will ask this question and check the answer before retrieving the password.

The PasswordRecovery control requires your application to forward emails to Simple Mail Transfer Protocol (SMTP) servers. You can customize the text and format of emails sent to users by setting the MailDefinition attribute.

Note:

The password information in the email is sent in plaintext. Its MailDefinition attribute is set to customize email.

The following code:

 
 
  1. < asp:PasswordRecovery ID="PasswordRecovery1" Runat="server"     SubmitButtonText="Get Password" SubmitButtonType="Link"> 
  2.   < MailDefinition From="administrator@Contoso.com"     Subject="Your new password"    BodyFileName="PasswordMail.txt" /> 
  3. < /asp:PasswordRecovery> 

ASP. NET Login control Extension: CreateUserWizard Control

The CreateUserWizard control collects information provided by potential users. By default, the CreateUserWizard control adds new users to the ASP. NET membership system.

The CreateUserWizard control collects the following user information:

User Name

Password

Confirm Password

Email Address

Security Prompt

Security answer

This information is used to authenticate the user and retrieve the user password if necessary ).

Note:

The CreateUserWizard control inherits from the Wizard control.

The following code:

 
 
  1. < asp:CreateUserWizard ID="CreateUserWizard1" Runat="server"     ContinueDestinationPageUrl="~/Default.aspx"> 
  2.   < WizardSteps> 
  3.     < asp:CreateUserWizardStep Runat="server"       Title="Sign Up for Your New Account"> 
  4.     < /asp:CreateUserWizardStep> 
  5.     < asp:CompleteWizardStep Runat="server"       Title="Complete"> 
  6.     < /asp:CompleteWizardStep> 
  7.   < /WizardSteps> 
  8. < /asp:CreateUserWizard> 

ASP. NET Login control Extension: ChangePassword Control

You can change the password of the ChangePassword control. You must first provide the original password, and then create and confirm the new password. If the original password is correct, the user password is changed to the new password. This control also supports sending emails about the new password.

The ChangePassword control contains two templated views displayed to the user. The first template is ChangePasswordTemplate, which displays the user interface used to collect the data required to change the user password. The second template is SuccessTemplate, which defines the user interface displayed after the user password is changed successfully.

The ChangePassword control is used by authenticated and unauthenticated users. If the user does not pass authentication, the control prompts the user to enter the login name. If the user has passed authentication, the control will fill the text box with the user's login name.

  1. Comments on ASP. net web controls
  2. ASP. NET Control Learning Summary
  3. ASP. NET front-end controls comment: Avoid obsessive-compulsive disorder and rush to simple and efficient
  4. Shell functions in ASP. NET 2.0 Environment
  5. Batch insert data to the database in ASP. NET 2.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.