Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity ResetPassword Method

WebSecurity - ResetPassword()


WebSecurity Object WebSecurity object


define

ResetPassword() The method resets the user's password using a password token.


C# and VB syntax

WebSecurity.ResetPassword(

passwordResetToken,newPassword)


Parameters

Parameters Type Description
passwordResetToken String The password token
newpassword String The new password

Return Value

Type Description
Boolean Returns if the password is changed true; otherwise, returns false。

Errors and exceptions

In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:


Notes

If the user has forgotten the password, use the ResetPassword method.

The ResetPassword method requires a passwordreset token。

The confirmation token can be created via the CreateAccount()、 CreateUserAndAccount() or GeneratePasswordResetToken() method.

The password can be reset via code, but the general procedure is to send an email to the user (with the token and a link to the page) so the user can confirm the new password with the new token:

@{

newPassword = Request["newPassword"];

confirmPassword = Request["confirmPassword"];

token = Request["token"];

if isPost

{

    // input testing is ommitted here to save space

    retunValue = ResetPassword(token, newPassword);

}

}

Change Password


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object