Generates a password reset token that can be sent to a user in email.
Assembly: WebMatrix.WebData (in WebMatrix.WebData.dll)
public static function GeneratePasswordResetToken( userName : String, tokenExpirationInMinutesFromNow : int ) : String
- Type: System.String
The user name.
- Type: System.Int32
(Optional) The time in minutes until the password reset token expires. The default is 1440 (24 hours).
Return ValueType: System.String
A token to send to the user.
The SimpleMembershipProvider.Initialize(String, NameValueCollection) method was not called.
The InitializeDatabaseConnection() method was not called.
The SimpleMembershipProvider membership provider is not registered in the configuration of your site. For more information, contact your site's system administrator.
If users have forgotten their password, they can request a new one. To provide a new password, do the following:
Create a password-reset page that has a field where users can enter their email address.
When a user has entered his or her email address in the password-reset page, verify that the email address represents a valid user. If it does, generate a password reset token by calling the method.
Create a hyperlink that points to a confirmation page in your site and that includes the token as a query-string parameter in the link's URL.
Send the link to a user in an email message. When the user receives the email message, he or she can click the link to invoke the confirmation page.
Create a confirmation page that extracts the token from the URL parameter and that lets the user enter a new password.
When the user submits the new password, call the ResetPassword(String, String) method and pass the password reset token and the new password. If the token is valid, the password will be reset. If the token is not valid (for example, it has expired), display an error message.
The Starter Site template includes pages that show how to reset a password by using the method. The initial steps described are in the ForgotPassword.cshtml file, and the subsequent steps are in the PasswordReset.cshtml file.