WebSecurity IsAuthenticated 属性
websecurity 属性 - isauthenticated

定义
isauthenticated 属性是一个布尔值,指示当前用户是否已通过身份验证(已登录)。
如果当前用户已通过身份验证,则该属性值是一个布尔值 true,否则是 false。
c# 和 vb 语法
websecurity.isauthenticated
实例
实例 c#
if (!websecurity.isauthenticated)
{
response.redirect("~/account/login");
}
{
response.redirect("~/account/login");
}
实例 vb
if !websecurity.isauthenticated then
response.redirect("~/account/login")
end if
response.redirect("~/account/login")
end if
备注
isauthenticated 属性是只读的。它不能通过代码更改。
错误和异常
在下面的情况下,任何对 websecurity 对象的访问将抛出一个 invalidoperationexception:
- initializedatabaseconnection() 方法没有被调用
- simplemembership 没有初始化(或者在网站配置中禁用)
技术数据
名称 | 值 |
---|---|
namespace | webmatrix.webdata |
assembly | webmatrix.webdata.dll |

相关文章
- ASP.NET Web Pages 教程
- ASP.NET Web Pages Razor
- ASP.NET Web Pages HTML 表单
- ASP.NET Web Pages WebGrid
- ASP.NET Web Pages 图表
- ASP.NET Web Pages Email
- ASP.NET Web Pages PHP
- ASP.NET Web Pages – 发布
- ASP.NET WebPages 帮助器参考手册
- ASP.NET Razor C# 循环和数组
- ASP.NET Razor C# 逻辑
- ASP.NET Razor VB 循环和数组
- ASP.NET MVC 数据库
- ASP.NET MVC – 发布
- ASP.NET Web Forms 教程
- ASP.NET ViewState
- ASP.NET ArrayList
- ASP.NET SortedList
- ASP.NET XML 数据绑定
- ASP.NET 数据库连接