WebSecurity- CreateAccount()
❮WebSecurity
意味
CreateAccount()メソッドは、ユーザー名とパスワードを使用してユーザーデータベースに新しいアカウントを作成し、オプションで、ユーザーがアカウントを明示的に確認する必要があるかどうかを指定できます。
C#およびVB構文
WebSecurity.CreateAccount(username,
password, requireConfirmation)
パラメーター
Parameter | Type | Description |
---|---|---|
userName | String | The user name |
password | String | The user password |
requireConfirmation | Boolean | true if the account must be confirmed using the token return value, default is false. |
戻り値
Type | Description |
---|---|
String | A token that can be sent to the user to confirm the account. |
エラーと例外
次の場合、 WebSecurityオブジェクトにアクセスすると、 InvalidOperationExceptionがスローされます。
- InitializeDatabaseConnection()メソッドが呼び出されていません
- SimpleMembershipが初期化されていない(またはWebサイト構成で無効になっている)
CreateAccount()メソッドは、次の場合にもMembershipCreateUserExceptionをスローします。
- ユーザー名は空です
- ユーザー名にはすでにメンバーシップアカウントがあります
- パスワードが空です
- パスワードが長すぎます
- データベース操作が失敗しました
❮WebSecurity