This documentation is archived and is not being maintained.

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()

ExceptionCondition
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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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, 3.0, 2.0
Show: