his tutorial will show how you can set up membership and user login for a website using ASP.NET 2.0

In Visual Studio, Website > ASP.NET Configuration will take us to the Web Site Administration Tool. We need to go on the Security tab and then choose ‘Use the security Setup Wizard to configure security step by step’. We will choose the options ‘From the Internet’, but do not need to Enable Roles for this tutorial. Choose a username, password, email and security question & answer.
Back on the Security page, chose Create Access Rules. Click on the page/directory you want to restrict access to and choose ‘Anonymous Users’ and ‘Deny’. Then click Ok.
In order to email when a new user has been created, you can set up the SMTP server details in the Administration Tool.

From the Toolbox, you’ll notice there is a whole section dedicated to Login features. You can use the LoginStatus to show whether a user is logged in or not (and provide a link to log in or log out).

  • The Login control will let a user log in to the website with their username and password.
  • We can also use a Validation Summary control and set its ValidationGroup to the ID of the Login control.
  • The LoginView control will let you specify content viewable by both logged in members and anonymous users.
  • We can use the LoginName control to output the username of the currently logged in user.
  • If we create a page in the directory that we have set an access rule for, anonymous users will not be allowed to view them. Instead, they will be asked to log in.

We can add a CreateUserWizard control to allow users to register themselves.
We can also let users change their own password with the ChangePassword control.
You can also add a PasswordRecovery control, but must have SMTP server settings correctly configured in the Adminitration Tool.

So with the above controls implemented, no code has been written, and yet we have a multi-function log-in system on our website.

Here is what the homepage should look like:

The Login page should look something like this:




Download Source Files