我们正在使用 asp.net mvc 5 制作一个 Intranet 站点,但在 IE 9 中的兼容性设置存在一些问题。该站点需要在没有兼容性视图的情况下显示。
我们做了一些研究,做了这些:
1. 在 layout.cshtml 和 login.cshtml 中添加 meta
<!DOCTYPE html>
<html>
<head>
<title>@System.Web.Configuration.WebConfigurationManager.AppSettings["WebsiteTitle"]</title>
<meta http-equiv='X-UA-Compatible' content='IE=Edge'>
<meta http-equiv="PRAGMA" content="NO-CACHE">
....
@{Layout = null;}
@model ZdtcWebsite.Models.LoginModel
<!DOCTYPE html>
<html>
<head>
<title>@System.Web.Configuration.WebConfigurationManager.AppSettings["WebsiteTitle"]</title>
<meta http-equiv='X-UA-Compatible' content='IE=Edge'>
<meta http-equiv="PRAGMA" content="NO-CACHE">
<meta charset="utf-8" />
....
2.我们在web.config中添加customheader
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=Edge" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
这两个仍然不起作用。我们的网站在打开时仍会进入兼容模式。我注意到的一件事是,如果我们在 IE9 中打开开发人员工具并打开页面,X-UA-Compatible 标记正在工作,但如果开发人员工具关闭,则不会。
我们在 IE 11 上对此进行了测试,它运行良好。任何人都可以建议这里发生了什么?