Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity CreateUserAndAccount Method

WebSecurity - CreateUserAndAccount()


WebSecurity Object WebSecurity object


define

CreateUserAndAccount() The method uses a username and password to create a new account in the user database, and can optionally specify whether the user must explicitly confirm the account.


C# and VB syntax

WebSecurity.CreateUserAndAccount(

username, password, propertyValues, requireConfirmation

)


Parameters

Parameters Type Description
userName String Username
password String The user's password
propertyValues Object A dictionary containing additional user properties
requireConfirmation Boolean Returns the token used to confirm the account if confirmation is required true. By default it returns false。

Return Value

Type Description
String a token that can be sent to the user for account confirmation.

Notes

CreateUserAndAccount() The method inserts a new entry in the user profile table in the WebSecurity database, and then creates a matching entry in the membership table.

You can pass requireConfirmationToken to the parameter true to require that the account must be confirmed by the user. To confirm the account, you must obtain the token as the return value from the **CreateUserAndAccount()** method.

If you want to maintain the user profile table manually and only create a membership table entry for the user, call the **CreateAccount()** method.


Errors and exceptions

In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:

In the following cases,CreateUserAndAccount() the method also throws an MembershipCreateUserException:


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object