【问题标题】:X-UA-Compatible doesn't work in C# WebBrowser controlX-UA-Compatible 在 C# WebBrowser 控件中不起作用
【发布时间】:2013-06-28 09:51:25
【问题描述】:

我在 winforms WebBrowser 控件中加载了网页。该页面需要以 IE8 模式呈现,所以我将 X-UA-Compatible 设置为 IE=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" />

不幸的是,当我检查用户代理时,我仍然有 MSIE 7.0。 X-UA-Compatible 被忽略的原因是什么。当我直接在 IE9 中打开我的页面时,一切正常 - 文档模式切换到 IE8。

我的用户代理:

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)

【问题讨论】:

标签: c# winforms internet-explorer ie8-compatibility-mode


【解决方案1】:

"X-UA-Compatible" 仅影响 WebBrowser 控件内容模式,但不影响它将发送的 UserAgent Header。 (见https://blogs.msdn.microsoft.com/patricka/2015/01/12/controlling-webbrowser-control-compatibility/

此外,UserAgent 标头是 HTTP 请求的一部分,在服务器开始发送其响应时已经传输,包括任何“X-UA-Compatible”值。

【讨论】:

    猜你喜欢
    • 2013-10-16
    • 2017-03-09
    • 2013-04-10
    • 1970-01-01
    • 2013-12-29
    • 2014-12-08
    • 2013-02-20
    • 2012-02-03
    • 1970-01-01
    相关资源
    最近更新 更多