Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

WebSecurity Logout Method

WebSecurity - Logout()


WebSecurity Object WebSecurity object


define

Logout() The method logs out the current user.


C# and VB syntax

Logout()


Example

Example C#

// Log out

WebSecurity.Logout();

// Redirect back to the home page

Response.Redirect("~/");

Example VB

' Log out

WebSecurity.Logout()

' Redirect back to the home page

Response.Redirect("~/")


Parameters

none.


Return Value

none.


Errors and exceptions

In the following cases, any access to the WebSecurity object will throw an InvalidOperationException:


Notes

When a user is logged in, ASP.NET sets an authentication token in the cookie so ASP.NET knows about subsequent requests from the logged-in user.

Logout() The method removes the authentication token and logs out the user.


Technical data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

WebSecurity Object WebSecurity object