简体   繁体   English

X-UA兼容的Intranet站点在IE 9中不起作用

[英]X-UA-Compatible not working in IE 9 for intranet sites

we're making an intranet site with asp.net mvc 5, but have some issues with compatibility setting in IE 9. The site need to be displayed without compatibility view. 我们正在使用asp.net mvc 5创建一个Intranet站点,但是IE 9中的兼容性设置存在一些问题。该站点需要显示为不具有兼容性视图。
We did some research, and do these: 我们做了一些研究,并进行了以下工作:
1. add meta in layout.cshtml and login.cshtml 1.在meta.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. We add customheader in web.config 2.我们在web.config中添加customheader

<system.webServer>
<httpProtocol> 
        <customHeaders> 
          <clear />
          <add name="X-UA-Compatible" value="IE=Edge" /> 
        </customHeaders> 
     </httpProtocol> 
<validation validateIntegratedModeConfiguration="false" />
</system.webServer> 

Both of this still not working. 两者仍然无法正常工作。 Our site will still come in compatibility mode when opened. 打开后,我们的站点仍将以兼容模式进入。 One thing that I notice is that if we open developer tools in IE9 and open the page, the X-UA-Compatible tag is working, but not if developer tools is closed. 我注意到的一件事是,如果我们在IE9中打开开发人员工具并打开页面,则X-UA-Compatible标记会起作用,但是如果关闭了开发人员工具则不会。
We test this on IE 11 and it works fine. 我们在IE 11上对此进行了测试,并且效果很好。 Anybody can suggest what's happening here? 有人可以建议这里发生了什么吗?

Turns out it is because we have several "console.log" in our script. 原来是因为我们的脚本中有几个“ console.log”。 When we remove them the site works fine. 当我们删除它们时,该站点可以正常工作。 That's probably also the cause why the site works fine if developer tools is showed. 如果显示了开发人员工具,这也可能是该网站正常运行的原因。 I don't understand why there is any connection between console.log and compatibility view, but I guess there are 我不明白为什么console.log和兼容性视图之间没有任何联系,但是我想

The browser setting for compatibility mode overrides the document's preference (via meta tag) or the server's preference (via response header). 兼容模式的浏览器设置将覆盖文档的首选项(通过meta标记)或服务器的首选项(通过响应标头)。 The default IE compatibility view setting is to use compatibility mode for intranet sites. IE兼容性视图的默认设置是对Intranet站点使用兼容模式。 Go to Tools > Compatibility View settings in IE. 转到IE中的“工具”>“兼容性视图”设置。 There, you'll see a checkbox labeled "Display intranet sites in Compatibility View". 在那里,您将看到一个标记为“在兼容性视图中显示Intranet站点”的复选框。 If it's checked, uncheck it. 如果已选中,请取消选中它。 If you can't uncheck it because it's disabled, you'll have to talk with your organization's infrastructure team. 如果由于禁用它而不能取消选中它,则必须与组织的基础结构团队联系。 There's a GP (group policy) setting for this. 有一个GP(组策略)设置。

You'll likely need to talk with your organization's infrastructure team either way. 您可能需要以任何一种方式与组织的基础架构团队进行交谈。 Even if you can uncheck it yourself, unless you want to hold each user in your organization's hand so they can also uncheck it individually in their IEs, it would be far easier and standardized to make it unchecked via GP. 即使您自己可以取消选中它,除非您希望将每个用户都握在组织的手中,以便他们也可以在自己的IE中分别取消选中它,否则通过GP取消选中它会更加容易且标准化。

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

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