WebSecurity - CreateAccount()


WebSecurity 对象WebSecurity Object

Definition

CreateAccount()The method creates a new account in the user database using a username and password, and can optionally specify whether the user must explicitly confirm the account.


C# and VB Syntax

WebSecurity.CreateAccount(username, password, requireConfirmation)


Parameters

Parameter Type Description
userName String Username
password String User password
requireConfirmation Boolean If the account must be confirmed using the token return value, then returntrue. By default, returnfalse。


Return Value

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


Errors and Exceptions

In the following cases, anyWebSecurityaccess to the object will throw anInvalidOperationException:

  • InitializeDatabaseConnection()The method has not been called
  • SimpleMembershipnot initialized (or disabled in the website configuration)

In the following cases,CreateAccount()the method also throws anMembershipCreateUserException:

  • 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 对象WebSecurity Object Other Extensions