ASP.NET Web Pages - WebSecurity 对象
描述
WebSecurity ASP.NET Web Pages 证。
通过 WebSecurity 码等等。
WebSecurity 册 - 属性
| 属性 | 描述 |
|---|---|
| CurrentUserId | 户的 ID。 |
| CurrentUserName | |
| HasUserId | 具有用户 ID 是,返回 true。 |
| IsAuthenticated | 证状态。 |
WebSecurity 册 - 方法
| 属性 | 描述 |
|---|---|
| ChangePassword() | 密码。 |
| ConfirmAccount() | 帐户。 |
| CreateAccount() | 户帐户。 |
| CreateUserAndAccount() | 户帐户。 |
| GeneratePasswordResetToken() | 令牌。 |
| GetCreateDate() | 和时间。 |
| GetPasswordChangeDate() | 时间。 |
| GetPasswordFailures SinceLastSuccess() |
|
| GetUserId() | 户 ID。 |
| GetUserIdFrom PasswordResetToken () |
用户 ID。 |
| InitializeDatabaseConnection() | 。 |
| IsAccountLockedOut() | |
| IsConfirmed() | |
| IsCurrentUser() | |
| Login() | |
| Logout() | |
| RequireAuthenticatedUser() | 证,请将 HTTP 401)。 |
| RequireRoles() | 请将 HTTP 置为 401。 |
| RequireUser() | HTTP 401。 |
| ResetPassword() | 。 |
| UserExists() | 否存在。 |
技术数据
| 名称 | 值 |
|---|---|
| Class | WebMatrix.WebData.WebSecurity |
| Namespace | WebMatrix.WebData |
| Assembly | WebMatrix.WebData.dll |
初始化 WebSecurity 数据库
用 WebSecurity 初始化 WebSecurity 数据库。
在 web _AppStart.cshtml 页面。
码:
_AppStart.cshtml
@{
WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email",
true);
}
。它会对 WebSecurity 初始化。
"Users" 是 WebSecurity 称。(Users.sdf)
"UserProfile" 名称。
"UserId" 包含用户 ID
"Email" 。
数 true 否则 false。
true 。
WebSecurity 数据库
UserProfile ID email):
| UserId | |
|---|---|
| 1 | john@johnson.net |
| 2 | peter@peterson.com |
| 3 | lars@larson.eut |
Membership
出):
| UserId | 创建日期 | 确认 令牌 |
是否 确认 |
最后的 密码错误 |
密码 | 密码更改 |
|---|---|---|---|---|---|---|
| 1 | 12.04.2012 16:12:17 | NULL | True | NULL | AFNQhWfy.... | 12.04.2012 16:12:17 |
注释:,请通过 WebMatrix 每张表。
资格配置
使用 ASP.NET Web Pages 统 SimpleMembership会在使用 WebSecurity 错误。
点的 Web.config
<appSettings> <add key="enableSimpleMembership" value="true" /> </appSettings>