HTTP_USER_AGENT 和 navigator.userAgent 不一样,有什么想法吗?
我在客户端使用 Javascript,获取 navigator.userAgent
,返回:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E)
使用 C# Request.ServerVariables["HTTP_USER_AGENT"]
,返回:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
如您所见,它的 IE :(。
IE总是这样,还是只有我这样? 如何获得相同的值?
PS,我什至在本地 IIS 中尝试过此操作,结果相同
I use Javascript in client, get navigator.userAgent
, returns:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E)
use C# Request.ServerVariables["HTTP_USER_AGENT"]
, returns:
Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
As you can see, its IE :(.
IE always do this, or just me?
How to get the same value?
PS, I tried this even in local IIS, same results
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Internet Explorer 9 及更高版本中的用户代理字符串在 HTTP 请求中发送的版本与通过
navigator.userAgent
获取的版本之间几乎总是不同。这是因为字符串中所谓的特征标记。其背景解释如下:http:// /msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx来自 msdn 文档:
您必须决定要在应用程序中使用哪一个。没有办法“同步”它们。通过 Javascript 获得的应该包含更多信息......
The user agent string in Internet Explorer nine and higher will almost always differ, between the version send in the HTTP request and the one obtained via
navigator.userAgent
. This is because of the so called feature tokens in the string. The background for this is explained here: http://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspxFrom the msdn-document:
You must decide witch one you want to use in your application. There is no way to "synchronize" them. The one obtained via Javascript should contain more information...