Export (0) Print
Expand All

WebSecurity.ChangePassword Method

Changes the password for the specified user.

Namespace:  WebMatrix.WebData
Assembly:  WebMatrix.WebData (in WebMatrix.WebData.dll)

public static bool ChangePassword(
	string userName,
	string currentPassword,
	string newPassword
)

Parameters

userName
Type: System.String
The user name.
currentPassword
Type: System.String
The current password for the user.
newPassword
Type: System.String
The new password.

Return Value

Type: System.Boolean
true if the password is successfully changed; otherwise, false.

ExceptionCondition
InvalidOperationException

The SimpleMembershipProvider.Initialize(String, NameValueCollection) method was not called.

-or-

The InitializeDatabaseConnection() method was not called.

-or-

The SimpleMembershipProvider membership provider is not registered in the configuration of your site. For more information, contact your site's system administrator.

For an example of how to use the ChangePassword(String, String, String) method, see the ChangePassword.cshtml file in the Starter Site template.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Show:
© 2014 Microsoft