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

2.8k views Asked by At

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.
We did some research, and do these:
1. add meta in layout.cshtml and login.cshtml

<!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

<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.
We test this on IE 11 and it works fine. Anybody can suggest what's happening here?

2

There are 2 answers

1
Daniel W On BEST ANSWER

Turns out it is because we have several "console.log" in our script. 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

7
Chris Pratt On

The browser setting for compatibility mode overrides the document's preference (via meta tag) or the server's preference (via response header). The default IE compatibility view setting is to use compatibility mode for intranet sites. Go to Tools > Compatibility View settings in IE. There, you'll see a checkbox labeled "Display intranet sites in Compatibility View". 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.

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.