您的位置:58编程 > web中的属性是什么意思 WebSecurity IsAuthenticated 属性

web中的属性是什么意思 WebSecurity IsAuthenticated 属性

2023-05-11 06:33 ASP.NET教程

web中的属性是什么意思 WebSecurity IsAuthenticated 属性

web中的属性是什么意思 WebSecurity IsAuthenticated 属性

web中的属性是什么意思

WebSecurity 属性 - IsAuthenticated


WebSecurity 对象 WebSecurity 对象

定义

IsAuthenticated 属性是一个布尔值,指示当前用户是否已通过身份验证(已登录)。

如果当前用户已通过身份验证,则该属性值是一个布尔值 true,否则是 false


C# 和 VB 语法

WebSecurity.IsAuthenticated


实例

实例 C#

if (!WebSecurity.IsAuthenticated)
{
Response.Redirect("~/Account/Login");
}

实例 VB

if !WebSecurity.IsAuthenticated then
  Response.Redirect("~/Account/Login")
end if


备注

IsAuthenticated 属性是只读的。它不能通过代码更改。


错误和异常

在下面的情况下,任何对 WebSecurity 对象的访问将抛出一个 InvalidOperationException

  • InitializeDatabaseConnection() 方法没有被调用
  • SimpleMembership 没有初始化(或者在网站配置中禁用)

技术数据

名称
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity 对象 WebSecurity 对象
阅读全文
以上是58编程为你收集整理的web中的属性是什么意思 WebSecurity IsAuthenticated 属性全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 58编程 58biancheng.com 版权所有 联系我们
桂ICP备12005667号-32 Powered by CMS