WebSecurity Logout 方法

2018-09-27 16:43 更新

WebSecurity - Logout()


WebSecurity 對(duì)象 WebSecurity 對(duì)象

定義

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


C# 和 VB 語(yǔ)法

Logout()


實(shí)例

實(shí)例 C#

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

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

實(shí)例 VB

' Log out the current user
WebSecurity.Logout()

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


參數(shù)

無(wú)。


返回值

無(wú)。


錯(cuò)誤和異常

在下面的情況下,任何對(duì) WebSecurity 對(duì)象的訪問(wèn)將拋出一個(gè) InvalidOperationException

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

備注

當(dāng)用戶已登錄,ASP.NET 在 cookie 中設(shè)置一個(gè)身份驗(yàn)證令牌,讓 ASP.NET 知道用戶已登錄的后續(xù)請(qǐng)求。

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


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

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


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

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)