WebSecurity Logout 方法

2018-09-27 16:43 更新

WebSecurity - Logout()


WebSecurity 對象 WebSecurity 對象

定義

Logout() 方法注銷當前用戶。


C# 和 VB 語法

Logout()


實例

實例 C#

// Log out the current user
WebSecurity.Logout();

// Redirect back to the homepage
Response.Redirect("~/");

實例 VB

' Log out the current user
WebSecurity.Logout()

' Redirect back to the homepage
Response.Redirect("~/")


參數(shù)

無。


返回值

無。


錯誤和異常

在下面的情況下,任何對 WebSecurity 對象的訪問將拋出一個 InvalidOperationException

  • InitializeDatabaseConnection() 方法沒有被調(diào)用
  • SimpleMembership 沒有初始化(或者在網(wǎng)站配置中禁用)

備注

當用戶已登錄,ASP.NET 在 cookie 中設置一個身份驗證令牌,讓 ASP.NET 知道用戶已登錄的后續(xù)請求。

Logout() 方法移除身份驗證令牌,注銷用戶。


技術數(shù)據(jù)

名稱
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll


WebSecurity 對象 WebSecurity 對象
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號