WebSecurity - CreateAccount()
WebSecurity object
define
CreateAccount() 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.CreateAccount(
username, password, requireConfirmation
)
Parameters
| Parameters | Type | Description |
|---|---|---|
| userName | String | Username |
| password | String | The user's password |
| 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. |
Errors and exceptions
In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:
- InitializeDatabaseConnection() The method is not called
- SimpleMembership Not initialized (or disabled in the website configuration)
In the following cases,CreateAccount() the method also throws an MembershipCreateUserException:
- The username is empty
- The username already has a membership account
- The password is empty
- The password is too long
- The database operation failed
Technical data
| Name | Value |
|---|---|
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
WebSecurity object