WebSecurity CreateAccount method
definition
CreateAccount () method using the user name and password to create a new account in the user database, and you can specify whether the user must explicitly confirm the account as needed.
C # and VB syntax
WebSecurity.CreateAccount( username,
password, requireConfirmation )
parameter
参数 | 类型 | 描述 |
---|---|---|
userName | String | 用户名 |
password | String | 用户密码 |
requireConfirmation | Boolean | 如果账户必须使用令牌返回值进行确认,则返回 true 。默认返回 false 。 |
return value
类型 | 描述 |
---|---|
String | 可发送给用户进行帐户确认的令牌。 |
Errors and exceptions
In the following scenario, any access to WebSecurity object will throw an InvalidOperationException:
- InitializeDatabaseConnection () method has not been called
- SimpleMembership not initialized (or disabled in the site configuration)
In the following cases, CreateAccount () method also throws a MembershipCreateUserException:
- User name is empty
- Username already have a member account
- Password is empty
- Password is too long
- Database operation failed
Technical data
名称 | 值 |
---|---|
Namespace | WebMatrix.WebData |
Assembly | WebMatrix.WebData.dll |
WebSecurity objects