簡體   English   中英

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

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

我有一個Internet應用程序,因此在兼容性視圖中默認情況下是IE9。 我使用X-UA-Compatible標志。 我以HTTP標頭和Meta-Tag的形式發送了它。 IE9似乎接受它並使用IE9渲染引擎。 但是它仍然始終發送IE-7 UserAgent字符串。

有什么方法可以避免它,或者將該IE9識別為非IE7瀏覽器?

我真的不想使用瀏覽器的白名單,而是不支持的瀏覽器(IE 5、6、7和8)的黑名單。

我的例子:

我正在打開頁面,因此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

然后,我的服務器正在回答:

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>

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

謝謝

我不是想恢復舊線程,但是如果有人遇到這個問題,他們可能會發現這個有趣: Internet Explorer 11的許多用戶代理字符串

如果用戶選擇在“兼容性視圖”中渲染網站(單擊“工具”>“兼容性視圖設置”),則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)

默認情況下,Intranet區域中的站點在“兼容性”視圖中呈現,因此這是他們將看到的User-Agent字符串。

所以我用IE9做了一個測試:

在(正常模式)下,您得到

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

在兼容模式下,您得到

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