69pao国产精品视频-久久精品一区二区二三区-精品国产精品亚洲一本大道-99国产综合一区久久

WebSecurity IsAuthenticated 屬性

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 對象
相關文章