AnonymousId总是空 [英] AnonymousId is always null

查看:930
本文介绍了AnonymousId总是空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET MVC的网站。当错误在网站上出现,我想与 Request.AnonymousID 的值一起记录异常,要能够发现,如果一个用户正在经历20个错误,或20个用户遇到了同样的错误。下面已被添加到的web.config 文件:

I have an ASP.NET MVC site. When errors occur on the site, I would like to log the exception along with the value of Request.AnonymousID, to be able to spot if one user is experiencing 20 errors, or 20 users experiencing the same error. The following has been added to the web.config file:

<system.web>
  <anonymousIdentification enabled="true" />
  ...
</system.web>

虽然在Visual Studio中开发和使用IIS防爆preSS,这个工程按预期。但是,当网站移动到测试环境(运行IIS 8.5的Windows Server 2012 R2上) Request.AnonymousID 的值总是空。

匿名身份验证,也配置了IIS中的网站。在配置中的每个变化之后,我尝试重新启动该网站,回收应用程序池,并在浏览器中清除Cookie - 似乎没有任何工作。在 .ASPXANONYMOUS Cookie会产生,但ID始终是空的,当我尝试在code使用它。

Anonymous Authentication has also been configured for the site in IIS. After each change in configuration I try restarting the site, recycling the application pool, and clearing cookies in my browser - nothing seems to work. The .ASPXANONYMOUS cookie gets generated, but the ID is always empty when I try to use it in the code.

我甚至尝试创建一个虚拟的快速现场,只显示在页面上AnonymousId,它工作在测试环境中,所以我不能找出我在现场实际做错了。

I even tried creating a quick dummy-site that only shows the AnonymousId on the page, and it works on the Test environment, so I can't figure out what I am doing wrong in the actual site.

任何帮助将大大AP preciated。



修改1:
我已经添加以下​​内容的Global.asax ,以生成自定义AnonymousId:

Any help would be greatly appreciated.


Edit 1: I've added the following to Global.asax, in order to generate a custom AnonymousId:

protected void AnonymousIdentification_Creating(object sender, AnonymousIdentificationEventArgs args)
{
    string id = string.Format("Test-{0}", Guid.NewGuid());
    args.AnonymousID = id;
}

同样,这个工作我的机器上并在测试服务器上的虚拟我的现场,但在实际的网站。

Again, this works on my machine and on my dummy-site on the Test-server, but not in the actual site.

该网站是一个子网站(例如的mysite .domain.com),如果有什么差别。虚设网站也是一个子网站,但这里的匿名认证工作开箱即用。

The site is a sub-site (e.g. mysite.domain.com), if that makes any difference. The dummy-site is also a sub-site, but here the anonymous authentication worked "out of the box".

编辑2:看来 AnonymousId 不再为空在测试环境在网站上。它现在填充在事件处理程序中提供的格式加入的Global.asax 。因此,尽管它看起来像我拥有了一切设置正确,我还是想知道什么可以有$ P $的产生pvented的ID。它是一个配置问题?我不是在做正确的顺序东西(重启服务器/回收应用程序池,清除Cookies等)?

Edit 2: It seems the AnonymousId is no longer null on the site in the Test-environment. It is now populated with the format supplied in the eventhandler added to Global.asax. So while it seems like I had set everything up correctly, I would still like to know what could have prevented the Id from being generated. Was it a configuration issue? Did I not do things in the correct order (restart server / recycle app pool, clear cookies, etc.)?

推荐答案

这应该工作。有主机名和ASPXANONYMOUS饼干

This should work. There is no correlation between hostname and the ASPXANONYMOUS cookie

检查是否安装了IIS匿名身份验证模块,什么是它设置为。我见过未安装该模块实例。

Check if Anonymous Authentication Module is installed on IIS and what is it set to. I have seen instances where this module is not installed.

这篇关于AnonymousId总是空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆