AnonymousIdentificationModule.ClearAnonymousIdentifier 方法
定义
清除与某个会话关联的匿名 Cookie 或标识符。Clears the anonymous cookie or identifier associated with a session.
public:
static void ClearAnonymousIdentifier();
public static void ClearAnonymousIdentifier ();
static member ClearAnonymousIdentifier : unit -> unit
Public Shared Sub ClearAnonymousIdentifier ()
例外
在匿名标识未启用时调用 ClearAnonymousIdentifier()。Calling ClearAnonymousIdentifier() when the anonymous identification is not enabled.
- 或 --or- 发出当前请求的用户是匿名的。The user for the current request is anonymous.
注解
ClearAnonymousIdentifier方法删除与网站上的会话相关联的匿名标识符。The ClearAnonymousIdentifier method removes the anonymous identifier associated with a session on a Web site. ClearAnonymousIdentifier当用户切换到与用户 ID 相关联的经过身份验证的会话(例如,事件发生时)时,使用方法可删除与会话关联的匿名标识符 MigrateAnonymous 。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.
由于在删除当前匿名标识符时将立即发出一个新的匿名标识符,因此, ClearAnonymousIdentifier NotSupportedException 如果在通过匿名标识符标识会话时调用,则该方法将引发。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.
如果站点使用 cookie,则该 ClearAnonymousIdentifier 方法将发出一个 clear cookie,以从浏览器中删除匿名标识符。If the site is using cookies, the ClearAnonymousIdentifier method issues a clear cookie to remove the anonymous identifier from the browser. 即使在以前的请求中未发送匿名 cookie,也会发出明文 cookie。The clear cookie is issued even if an anonymous cookie was not sent on the previous request.
明文 cookie 的构造如下所示:The clear cookie is constructed as follows:
如果浏览器支持 cookie 中的空字符串,则会以空字符串作为其值发出 cookie;否则,会以 "NoCookie" 作为其值发出 cookie。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.
Cookie 名称、路径和域的值设置为在 Web 应用程序的配置文件中配置的默认值。The values for the cookie name, path, and domain are set to the defaults configured in the Web application's configuration file.
过期日期设置为1999年10月12日。The expiration date is set to October 12, 1999.
如果站点使用无 cookie 身份验证,并且 URL 中存在匿名标识符,则会从 URL 中删除匿名标识符。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. 修改 URL 后,将发出一个重定向以返回当前正在执行的页。After the URL is modified, a redirect is issued to return to the currently executing page.