Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Logout Method

ClientFormsAuthenticationMembershipProvider.Logout Method

Logs out the user.

Namespace:  System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public function Logout()


The IsOffline property value is false and the membership provider is unable to access the authentication service.

The Logout method clears all authentication cookies from the cookie cache and resets the static Thread.CurrentPrincipal property to a WindowsPrincipal object that contains the current WindowsIdentity.

After you call this method, the current user is no longer authenticated for client application services. This means that you cannot retrieve roles through the ClientRoleProvider class and settings through the ClientSettingsProvider class. However, because the user might have a valid Windows identity, you might still receive a true value from code such as the following: Thread.CurrentPrincipal.Identity.IsAuthenticated. To determine whether the user is authenticated for client application services, confirm that the Identity property value of the IPrincipal retrieved through the static CurrentPrincipal property is a ClientFormsIdentity reference. Then, check the ClientFormsIdentity.IsAuthenticated property.

To reauthenticate the current user, call the ClientFormsAuthenticationMembershipProvider.ValidateUser method or the static Membership.ValidateUser method.

The following example code demonstrates how to use this method to log out the user.

No code example is currently available or this language may not be supported.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5

Community Additions

© 2015 Microsoft