ASP.NET Web Pages – Reset Password

[ This is an 8 part tutorial, previous tutorial: Forgot Password ]

In the reset password page insert the following:

var token = Request["token"];
if (IsPost)

var Password = Request["Password"];
var ConfirmPassword = Request["ConfirmPassword"];
Validation.RequireFields("Password", "ConfirmPassword");
Validator.StringLength(16, 6)
if (ConfirmPassword != Password)
    Validation.AddFormError("Sorry passwords do not match");

We ensure that the data is valid and the new passwords match. The token is received from the URL. When the user follows the reset link in their email it will look like this: http://localhost:1234/account/resetpasword?token=567dfsfsfs

if (Validation.IsValid())
if (WebSecurity.ResetPassword(token, Password))
}else {
    Validation.AddFormError("An error has occurred.");

If the data is valid, reset the password. The method takes two arguments: token and new password.


<form method="post">
<legend>Reset Password</legend>
<input type="password" name="Password" />
<label>Confirm Password</label>
<input type="password" name="ConfirmPassword" />
<input type="submit" value="Register"/>

You have now successfully created the core membership system. Next we will add the logout and change password pages, which should be in the members folder.

[ Continue,  Logout and Change Password ]