internet-explorer - HTTP_USER_AGENT 和 navigator.userAgent 不一样,知道吗?

标签 internet-explorer user-agent

我在客户端使用 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 总是这样做,还是只是我?
如何获得相同的值(value)?

PS ,我什至在本地 IIS 中也尝试过,结果相同

最佳答案

Internet Explorer 9 和更高版本中的用户代理字符串几乎总是不同的,在 HTTP 请求中发送的版本和通过 navigator.userAgent 获得的版本之间。 .这是因为字符串中有所谓的特征标记。此处解释了此背景:http://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx

从 msdn 文档:

Earlier versions of Internet Explorer included feature tokens defined using the Pre-Platform and Post-Platform keys part of the user-agent string during the HTTP negotiation process. Over time, this lead to overly long user-agent strings, which in turn created problems for certain web servers. Problems usually appeared when user-agent strings were longer than 256 characters. As of Internet Explorer 9, the user-agent string no longer includes feature tokens during HTTP negotiation. Feature tokens are included in the value returned by the userAgent property of the navigator object. Applications that rely on the earlier behavior should be modified accordingly.



您必须决定要在应用程序中使用的女巫。没有办法“同步”它们。通过Javascript获得的应该包含更多信息......

关于internet-explorer - HTTP_USER_AGENT 和 navigator.userAgent 不一样,知道吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9104182/

相关文章:

html - 如何覆盖用户代理 CSS

java - 使用 UADetector 检测机器人

css - 删除 Surface 3 IE 上的透明浅灰色高光

javascript - 如何将下一个/上一个按钮添加到 Surface 平板电脑触摸幻灯片?

jquery - 即问题。嵌套相对 DIV 不随滚动移动

javascript - 从 Google Chrome 扩展检测操作系统

http-headers - 更改 wget 中的默认 USER-AGENT 和 REFERRER 值

linux - 如何统计Linux日志文件中 'Mozilla'用户代理的数量

css - Firefox+CHrome 中的额外填充/边距 IE 中无

javascript - JS split() 在 IE10 及以下版本出错