WebSecurity CreateUserAndAccount method
definition
CreateUserAndAccount () 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
parameter
参数 | 类型 | 描述 |
---|---|---|
userName | String | 用户名 |
password | String | 用户密码 |
propertyValues | Object | 一个包含额外的用户属性的字典 |
requireConfirmation | Boolean | 如果账户必须使用令牌返回值进行确认,则返回 true 。默认返回 false 。 |
return value
类型 | 描述 |
---|---|
String | 可发送给用户进行帐户确认的令牌。 |
Remark
CreateUserAndAccount () method in WebSecurity users in the database table to create a new entry, and then create a matching entry in the member table.
You can pass true as requireConfirmationToken parameters must be requested by the user to confirm the account. To confirm your account, you must obtain a token as a return value from CreateUserAndAccount () method.
If you want to manually maintain user information table, and you only want to create a membership table entry for the user, call CreateAccount () method.
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, CreateUserAndAccount () 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