Easy Tutorial
❮ Webpages Ref Websecurity Control Adrotator ❯

WebSecurity - Logout()


Definition

The Logout() method logs out the current user.


C# and VB Syntax


Example

Example C

// Logout from WebSecurity.Logout();
// Redirect to homepage Response.Redirect("~/");

Example VB

' Logout from WebSecurity.Logout()
' Redirect to homepage Response.Redirect("~/")

Parameters

None.


Return Value

None.


Errors and Exceptions

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


Remarks

When a user is logged in, ASP.NET sets an authentication token in a cookie to let ASP.NET know that the user is logged in for subsequent requests.

The Logout() method removes the authentication token, logging out the user.


Technical Data

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

❮ Webpages Ref Websecurity Control Adrotator ❯