AnonymousIdentificationModule.ClearAnonymousIdentifier Method

Clears the anonymous cookie or identifier associated with a session.

Namespace: System.Web.Security
Assembly: System.Web (in system.web.dll)

'Declaration
Public Shared Sub ClearAnonymousIdentifier
'Usage

AnonymousIdentificationModule.ClearAnonymousIdentifier
public static void ClearAnonymousIdentifier ()
public static function ClearAnonymousIdentifier ()
Not applicable.

Exception typeCondition

NotSupportedException

Calling ClearAnonymousIdentifier when the anonymous identification is not enabled.

-or-

The user for the current request is anonymous.

The ClearAnonymousIdentifier method removes the anonymous identifier associated with a session on a Web site. Use the ClearAnonymousIdentifier method to remove the anonymous identifier associated with a session when the user switches to an authenticated session associated with a user ID, for example when the MigrateAnonymous event occurs.

Since a new anonymous identifier will be issued immediately if the current anonymous identifier is removed, the ClearAnonymousIdentifier method will throw a NotSupportedException if it is called while the session is identified by an anonymous identifier.

If the site is using cookies, the ClearAnonymousIdentifier method issues a clear cookie to remove the anonymous identifier from the browser. The clear cookie is issued even if an anonymous cookie was not sent on the previous request.

The clear cookie is constructed as follows:

  • If the browser supports empty strings in a cookie, the cookie is issued with the empty string as its value; otherwise, the cookie is issued with "NoCookie" as its value.

  • The values for the cookie name, path, and domain are set to the defaults configured in the Web application's configuration file.

  • The expiration date is set to October 12, 1999.

If the site is using cookieless authentication, and an anonymous identifier is present in the URL, the anonymous identifier is removed from the URL. No other changes are made to the address or query string. After the URL is modified, a redirect is issued to return to the currently executing page.

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: