简体   繁体   中英

IE9 is ignoring X-UA-Compatible flag for UserAgent

I've an internet Application, so the IE9 is per default in the Compatibility View. I use the X-UA-Compatible flag. I sent it in the HTTP Header and as Meta-Tag. IE9 seems to accept it and use the IE9 rendering engine. But its still always sending the IE-7 UserAgent string.

Is there any way to avoid it, or to identify this IE9 as a not IE7 browser?

I really dont want to use a whitelist of browsers, but a blacklist of not-supported browsers (IE 5, 6, 7 & 8).

My example:

I'm opening the page so the IE9 is sending an an GET request:

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:

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

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:

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.

So I did a test with 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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