我在客户端使用 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/