Creates a new membership account using the specified user name and password and optionally lets you specify that the user must explicitly confirm the account.
Assembly: WebMatrix.WebData (in WebMatrix.WebData.dll)
'Declaration Public Shared Function CreateAccount ( _ userName As String, _ password As String, _ requireConfirmationToken As Boolean _ ) As String 'Usage Dim userName As String Dim password As String Dim requireConfirmationToken As Boolean Dim returnValue As String returnValue = WebSecurity.CreateAccount(userName, _ password, requireConfirmationToken)
- Type: System.String
The user name.
- Type: System.String
- Type: System.Boolean
(Optional) true to specify that the account must be confirmed by using the token return value; otherwise, false. The default is false.
Return ValueType: System.String
A token that can be sent to the user to confirm the account.
username is empty.
username already has a membership account.
password is empty.
password is too long.
The database operation failed.
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.
This method creates a new entry in the membership table of the membership database. It presumes that matching user information (represented by userName) already exists in the user profile table. (To create a new user in both the membership table and in the user profile table, use the CreateUserAndAccount(String, String, Object, Boolean) method.) When you call this method, the membership system verifies that a user profile record exists that matches the name that you pass in username. (The method queries the table that you specified in the userTableName parameter and the column specified in the userNameColumn column when you called the InitializeDatabaseConnection method in order to initialize membership.) It then creates a new entry in the membership table, using the user ID of the corresponding record in the user profile table.
You can pass true for requireConfirmationToken in order require that the user account must be confirmed by the user. To confirm the account, you get the token as the return value from this method. You then send an email message to the user that contains a link whose URL contains the token. When the user clicks the link, the request is sent to your application, where you extract the token from the link and then call the ConfirmAccount(String) method.
For an example of how to create a new user account by using the method, how to create a link that contains the confirmation token, and how to email the link to the user, see the Register.cshtml file in the Starter Site template.
For an example of how to use the confirmation token, see the Confirm.cshtml file in the Starter Site template.