Generates a random password that is at least 14 characters long.
Namespace:
System.Web.Security
Assembly:
System.Web (in System.Web.dll)
Visual Basic (Declaration)
Public Overridable Function GeneratePassword As String
Dim instance As SqlMembershipProvider
Dim returnValue As String
returnValue = instance.GeneratePassword()
public virtual string GeneratePassword()
public:
virtual String^ GeneratePassword()
public function GeneratePassword() : String
Return Value
Type:
System..::.StringA random password that is at least 14 characters long.
The Membership class provides a GeneratePassword method, which generates a password of a specified size with at least the specified number of non-alphabetic characters. The GeneratePassword method of the SqlMembershipProvider calls the GeneratePassword method of the Membership class to retrieve a random password that is at least 14 characters long. If the MinRequiredPasswordLength property is greater than 14, the password returned will be the length specified in the MinRequiredPasswordLength property.
You can specifically call the GeneratePassword method by referencing the SqlMembershipProvider class directly from the Provider property of the Membership class.
The generated password only contains alphanumeric characters and the following punctuation marks: !@#$%^&*()_-+=[{]};:<>|./?. No hidden or non-printable control characters are included in the generated password.
The following code example generates a random 10-character password.
Dim p As SqlMembershipProvider = CType(Membership.Provider, SqlMembershipProvider)
Dim newPassword As String = p.GeneratePassword()
SqlMembershipProvider p = (SqlMembershipProvider)Membership.Provider;
string newPassword = p.GeneratePassword();
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0, 2.0
Reference
Other Resources