【发布时间】:2011-12-16 20:16:43
【问题描述】:
我正在使用Flot 绘图库。它在 IE8 和 IE9 中似乎工作正常,但在 IE9 兼容性视图中出现问题 - 它不呈现任何图形。我怀疑这是因为它大量使用了 HTML5 canvas 对象,但我可能错了。我尝试执行以下操作:
-
将:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />添加到我的 HTML<head></head>标记中。我什至尝试过IE=8和IE=9,但这也没有帮助。我的标签如下所示:<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.1EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="X-UA-Compatible" content="IE=8" /> ... </head> <body> ... </body> </html> -
因为我仍然看到问题,所以我将以下内容添加到我的 Global.asax.cs 文件中:
void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown Response.Headers.Add("X-UA-Compatible", "IE=Edge"); }
我仍然面临这个问题。我得到的错误是这样的:
HTML1202: http://intranetdomain/SampleProj/Default.aspx is running in Compatibility View because 'Display intranet sites in Compatibility View' is checked.
Default.aspx
HTML1113: Document mode restart from IE7 Standards to IE9 Standards
Default.aspx
有没有办法克服这个问题?
编辑:检查我的响应标题,在Global.asax.cs 中添加该行并没有将它们添加到我的标题中。我想知道为什么。
响应标头:
Key Value
Response HTTP/1.1 200 OK
Cache-Control private
Content-Type text/html; charset=utf-8
Server Microsoft-IIS/7.5
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Thu, 27 Oct 2011 20:39:55 GMT
Content-Length 29088
编辑 2:显然,Application_End 是错误的事件。相反,这样做会将元素注入到标题中:
void Application_BeginRequest(object sender, EventArgs e)
{
Response.Headers.Add("X-UA-Compatible", "IE=Edge");
}
但问题本身仍然存在。
【问题讨论】:
-
您是否尝试将其添加为
<head>之后的第一个标签? IE 似乎只有在元标记列表中第一个出现时才会对此做出响应。 -
@SliverNinja:是的。我把它作为我的第一个标签。还用我正在使用的确切标记更新了我的问题。
-
应该根据这里的流行反馈工作 (stackoverflow.com/questions/637039/…)。
-
在 Application_End 方法中添加响应标头是否有原因?那不应该在 Application_BeginRequest 方法中吗?
-
Application_End 不是正确的事件。试试
PreSendRequestHeaders(msdn.microsoft.com/en-us/library/…)
标签: c# asp.net internet-explorer html http