简体   繁体   English

X-UA兼容在C#WebBrowser控件中不起作用

[英]X-UA-Compatible doesn't work in C# WebBrowser control

I have webpage loaded in winforms WebBrowser control. 我在winforms WebBrowser控件中加载了网页。 That page need to be rendered in IE8 mode so I set X-UA-Compatible to IE=8 : 该页面需要以IE8模式呈现,因此我将X-UA-CompatibleIE=8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" >
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="PRAGMA" content="NO-CACHE" />

Unfortunately when I check user agent I still have MSIE 7.0. 不幸的是,当我检查用户代理时,我仍然拥有MSIE 7.0。 What can be the reason that X-UA-Compatible is ignored. X-UA-Compatible被忽略的原因可能是什么。 When I open my page directly in IE9 all is well - document mode is switched to IE8. 当我直接在IE9中打开页面时,一切都很好-文档模式已切换为IE8。

My 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; .NET4.0C; .NET4.0E; InfoPath.3)

"X-UA-Compatible" only affects the WebBrowser controls content mode, but not the UserAgent Header it would send. “ X-UA兼容”仅影响WebBrowser控件的内容模式,而不影响它将发送的UserAgent标头。 (see https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/ ) (请参阅https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/

Also, the UserAgent header is part of the HTTP request, which would have already been transmitted by the time the server starts sending its response, including any "X-UA-Compatible" value. 另外,UserAgent标头是HTTP请求的一部分,在服务器开始发送其响应时(包括任何“ X-UA-Compatible”值),该请求已经被发送。

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

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