自强学堂
自强学堂:学习、分享、让你更强!
Razor 实例HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

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("~/")


参数

无。


返回值

无。


错误和异常

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

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

备注

当用户已登录,ASP.NET 在 cookie 中设置一个身份验证令牌,让 ASP.NET 知道用户已登录的后续请求。

Logout() 方法移除身份验证令牌,注销用户。


技术数据

名称
NamespaceWebMatrix.WebData
AssemblyWebMatrix.WebData.dll


WebSecurity 对象 WebSecurity 对象