Share via


How to: Create an ASP.NET Login Page

You can create a login page using the ASP.NET Login control. This control takes a user name and password and uses ASP.NET membership and forms authentication to verify the user's credentials and create an authentication ticket. For information about configuring ASP.NET membership and forms authentication, see Introduction to Membership.

To create a login page

  1. Create an ASP.NET Web application that uses ASP.NET membership. For details and examples, see Configuring an ASP.NET Application to Use Membership.

  2. Create an ASP.NET Web page in your application named Login.aspx.

    NoteNote

    By default, ASP.NET forms authentication is configured to work with a page named Login.aspx. You can change the default login page name in the Web.config file for your application using the LoginUrl property.

  3. Add a Login control to the page.

  4. Optionally set the control's DestinationPageUrl property to the name of the page that the user will be redirected to after logging in. If you do not specify a value for the DestinationPageUrl property, the user will be redirected to the originally requested URL after being authenticated.

    The following example shows the markup for a Login control:

    <asp:Login 
      ID="Login1" 
      runat="server" 
      DestinationPageUrl="~/MembersHome.aspx">
    </asp:Login>
    

See Also

Reference

ASP.NET Login Controls Overview