[英]AnonymousID always returns null
I'm trying to get the AnonymousID in asp.net C# to be set when a user is not logged-in; 我正在尝试在用户未登录时在asp.net C#中设置AnonymousID。 in my Global.asax.cs file, I've added this class to set it: 在我的Global.asax.cs文件中,我添加了此类以对其进行设置:
protected void AnonymousIdentification_Creating(object sender, AnonymousIdentificationEventArgs e)
{
e.AnonymousID = Guid.NewGuid().ToString();
}
Then on my CurrentUser class, I did this: 然后在CurrentUser类上,执行以下操作:
userId = HttpContext.Current.Request.AnonymousID;
However the AnonymousID is always null, it never gets set. 但是AnonymousID 始终为 null,因此永远不会设置。
Note: a previous question on a similar issue was asked, but an actual resolution never posted: 注意:曾问过类似问题的先前问题,但从未发布过实际解决方案:
清除cookie,它将开始工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.