SimpleMembershipProvider.CreateAccount Method (String, String, Boolean)

Creates a new user account by using the specified user name and password.

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

public override string CreateAccount(
	string userName,
	string password,
	bool requireConfirmationToken


Type: System.String
The user name.
Type: System.String
The password.
Type: System.Boolean
(Optional) true to specify that the user account must be confirmed; otherwise, false. The default is false.

Return Value

Type: System.String
A token that can be sent to the user to confirm the user account.


username is empty.


username already has a user account.


password is empty.


password is longer than 128 characters.


A user record that corresponds to username does not exist in the UserTableName table (the user profile table).


The database operation failed.


The SimpleMembershipProvider class was not initialized using a call to the InitializeDatabaseConnection() method.

A user account is an entry in the membership table (by default, webpages_Membership). A user account record includes information such as the date that the account was created, the password, the date and time when the password was most recently changed, and so on. The user account table does not contain the user's name or email address; that information is stored instead in a user profile table. When you call the CreateAccount(String, String, Boolean) method, a user record that has the same user name (email address) as the account that you are trying to create must exist in the user profile table.

If the user profile record does not already exist and you want to create the user profile record and the membership account record at the same time, call CreateUserAndAccount(String, String, Boolean, IDictionary<String, Object>).

The token that this method returns can be sent to the user as part of a hyperlink that points to a confirmation page in your site. In the confirmation page, you can read the token and call the ConfirmAccount(String) method in order to confirm the account.

  • Medium trust for the immediate caller. This member can be used by partially trusted code.