How to: Create an ASP.NET Login Page
You can create a login page using the ASP.NET Login control. The control comprises text boxes, a check box and a button control. The text boxes collect username and password information. The check box and is used to remember the user's credentials and the button is used to submit the information the user provides. The login control simplifies the creation of login page for form authentication. This login 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. It a user selects remember me next time check box, the control creates a persistent cookie that remembers the user credentials. For information about configuring ASP.NET membership and forms authentication, see Introduction to Membership.
The login control functions, when you create an ASP.NET Web Site with membership, configure membership, create a membership user, and limit access to members only. For information about how to create a Website with membership, see Walkthrough: Creating a Web Site with Membership and User Login.
To create a login page
Create an ASP.NET Web application that uses ASP.NET membership. For details and examples, see Walkthrough: Creating a Web Site with Membership and User Login. For detailed information about how to configure membership, see Configuring an ASP.NET Application to Use Membership.
Create an ASP.NET Web page named Login.aspx in your application.
By default, ASP.NET forms authentication is configured to use 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.
Add a Login control to the page.
Set the control's DestinationPageUrl property to the name of the page that the user will be redirected to after logging in. For example, you can set the DestinationPageUrl to DestinationPageUrl="~/Membership/MembersHome.aspx", a members only page. If you do not specify a value for the DestinationPageUrl property, the user will be redirected to the original page the user requested page after successful log in.
The following example shows the markup for a Login control:
<asp:Login ID="Login1" runat="server" DestinationPageUrl="~/MembersHome.aspx"> </asp:Login>
You can set additional properties to customize the display for logged-in users. For information, see Walkthrough: Creating a Web Site with Membership and User Login