简体   繁体   English

IE9忽略了UserAgent的X-UA-Compatible标志

[英]IE9 is ignoring X-UA-Compatible flag for UserAgent

I've an internet Application, so the IE9 is per default in the Compatibility View. 我有一个Internet应用程序,因此在兼容性视图中默认情况下是IE9。 I use the X-UA-Compatible flag. 我使用X-UA-Compatible标志。 I sent it in the HTTP Header and as Meta-Tag. 我以HTTP标头和Meta-Tag的形式发送了它。 IE9 seems to accept it and use the IE9 rendering engine. IE9似乎接受它并使用IE9渲染引擎。 But its still always sending the IE-7 UserAgent string. 但是它仍然始终发送IE-7 UserAgent字符串。

Is there any way to avoid it, or to identify this IE9 as a not IE7 browser? 有什么方法可以避免它,或者将该IE9识别为非IE7浏览器?

I really dont want to use a whitelist of browsers, but a blacklist of not-supported browsers (IE 5, 6, 7 & 8). 我真的不想使用浏览器的白名单,而是不支持的浏览器(IE 5、6、7和8)的黑名单。

My example: 我的例子:

I'm opening the page so the IE9 is sending an an GET request: 我正在打开页面,因此IE9发送GET请求:

GET http://myserver/mypage/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg,     application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: de-CH
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: myserver
Cookie: MAKEBROWSERTEST=true

Then, my server is answering: 然后,我的服务器正在回答:

HTTP/1.1 302 Found
Cache-Control: private, no-cache="Set-Cookie"
Content-Type: text/html; charset=utf-8
Location: /myserver/mypage/two
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
Set-Cookie: MAKEBROWSERTEST=true; path=/
X-UA-Compatible: IE=edge
Date: Tue, 11 Sep 2012 10:04:21 GMT
Content-Length: 152

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/myserver/mypage/two">here</a>.</h2>
</body></html>

The IE9 is redirecting, but still sending the MSIE 7.0 User Agent: IE9正在重定向,但仍在发送MSIE 7.0用户代理:

GET http://myserver/mypage/two HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: de-CH
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.3; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: myserver
Cookie: MAKEBROWSERTEST=true

Thanks 谢谢

I'm not trying to revive an old thread, but if anyone comes across this, they might find this interesting: Internet Explorer 11's Many User-Agent Strings 我不是想恢复旧线程,但是如果有人遇到这个问题,他们可能会发现这个有趣: Internet Explorer 11的许多用户代理字符串

If the user chooses to render a site in Compatibility View (click Tools > Compatibility View Settings) then IE will send a User-Agent string that mimics Internet Explorer 7's UA string: 如果用户选择在“兼容性视图”中渲染网站(单击“工具”>“兼容性视图设置”),则IE将发送一个模仿Internet Explorer 7的UA字符串的User-Agent字符串:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)

By default, sites in the Intranet Zone render in Compatibility view, so this is the User-Agent string they'll see. 默认情况下,Intranet区域中的站点在“兼容性”视图中呈现,因此这是他们将看到的User-Agent字符串。

So I did a test with IE9: 所以我用IE9做了一个测试:

In (normal mode) you get 在(正常模式)下,您得到

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

In compatibility mode you get 在兼容模式下,您得到

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM