This documentation is archived and is not being maintained.

ClientFormsIdentity Class

Represents a user identity authenticated for client application services by using forms authentication.


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

public class ClientFormsIdentity : IIdentity, 

The ClientFormsIdentity type exposes the following members.

Public methodClientFormsIdentityInitializes a new instance of the ClientFormsIdentity class.

Public propertyAuthenticationCookiesGets a collection of the cookies retrieved from the authentication service.
Public propertyAuthenticationTypeGets the type of authentication that is used to authenticate the user.
Public propertyIsAuthenticatedGets a value indicating whether the user has been authenticated.
Public propertyNameGets the name of the user.
Public propertyProviderGets the membership provider that is used to authenticate the user.

Public methodDispose()Releases all resources used by the ClientFormsIdentity.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the ClientFormsIdentity and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRevalidateUserSilently authenticates the user by using cached credentials.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The client application services feature uses this class to represent an authenticated user. When you configure your application to use client application services and forms authentication, you can authenticate a user by calling the static Membership.ValidateUser method. After authentication, you can retrieve a reference to the current ClientFormsIdentity instance through the Identity property of the IPrincipal retrieved through the static Thread.CurrentPrincipal property. For more information, see Client Application Services.

You will typically access a ClientFormsIdentity object as an IIdentity reference to avoid a direct dependency on this class. You can determine whether a user is authenticated by checking the IIdentity.IsAuthenticated property of the identity. However, the user may be authenticated for Windows, but not for client application services. To determine whether the user is authenticated for client application services, you should also confirm that the IIdentity.AuthenticationType property value is "ClientForms".

You must use an explicit ClientFormsIdentity reference to call the RevalidateUser method, which is not defined by the IIdentity interface.

The following example code demonstrates how to use this class to silently revalidate a user when the application leaves the offline state. In this example, a CheckedChanged event handler updates the offline status to match the check box value. If the user sets the application to the online state, the event handler attempts to revalidate the user by calling the RevalidateUser method. However, if the authentication server is unavailable, the event handler returns the application to the offline state.


The RevalidateUser method is for convenience only. Because it does not have a return value, it cannot indicate whether revalidation has failed. Revalidation can fail, for example, if the user credentials have changed on the server. In this case, you might want to include code that explicitly validates users after a service call fails. For more information, see the Accessing Web Settings section in Walkthrough: Using Client Application Services.

private void workOfflineCheckBox_CheckedChanged(
    object sender, EventArgs e)
    ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked;
    if (!ConnectivityStatus.IsOffline)
            // Silently re-validate the user.

            // If any settings have been changed locally, save the new
            // new values to the Web settings service.

            // If any settings have not been changed locally, check 
            // the Web settings service for updates. 
        catch (System.Net.WebException)
                "Unable to access the authentication service. " +
                Environment.NewLine + "Staying in offline mode.",
                "Warning", MessageBoxButtons.OK, 
            workOfflineCheckBox.Checked = true;

.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.