1

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?

Daniel W
  • 1,092
  • 1
  • 12
  • 25
  • FYI, the meta tag *MUST* be the first tag in the Head tag, unless you have a content-type metatag, in which case that must come first and X-UA-Compatible must be second. It cannot come after the title as you have done here. When using the customHeaders, you shouldn't use the clear either. That wipes out other headers you may need. – Erik Funkenbusch Dec 19 '14 at 23:08
  • Tried to move the meta above title. But still not working. We added the header because we read somewhere that in some cases the existing header can messes up X-UA-Compatible. But still no luck – Daniel W Dec 20 '14 at 01:55
  • To be honest, not sure why you aren't getting errors.. the charset meta MUST come first. See https://code.google.com/p/doctype-mirror/wiki/MetaCharsetAttribute I think you may be unintentionally throwing your document into compatibility mode because of these errors. – Erik Funkenbusch Dec 20 '14 at 02:00
  • Hmm.. will try to test again in a couple of days. Will try your suggestion and get back to you on that – Daniel W Dec 20 '14 at 02:09

2 Answers2

2

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

Daniel W
  • 1,092
  • 1
  • 12
  • 25
  • We have the same problem, I will try this out - if it works, you sir have saved me several days of head banging and for that you must be severely rewarded – tommed Oct 16 '15 at 10:58
-1

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.

Chris Pratt
  • 232,153
  • 36
  • 385
  • 444
  • That's not true. The explicit document mode overrides the implicit compatibility view settings for local intranet (unless the site is explicitly added to the whitelist). Although I'm not sure if it overrides Enterprise mode settings, although this was just introduced in IE11 so shouldn't matter here. – Erik Funkenbusch Dec 19 '14 at 23:06
  • Actually it is true. I can attest first hand because our organization upgraded to Windows 7 last year, and it wrecked havoc on all our production sites internally, because they all switched to compatibility view. GP policy for sure overrides everything. Now a regular consumer instance may be different. I confess its been awhile since i tested that. But I know for a fact it at least previously did, and I find it suspect that IE would let a document overrule user settings. – Chris Pratt Dec 20 '14 at 01:14
  • Also, I'm not sure what you're talking about that was just introduced in IE11. Our infrastructure team deployed IE9 with compatibility view in GP, so enterprise support for this has been around since at least then. – Chris Pratt Dec 20 '14 at 01:17
  • It's called Enterprise Mode. http://msdn.microsoft.com/en-us/library/dn640687.aspx Yes, document mode overrules because the document knows how it needs to be rendered, a blanket rule does not. However, as I said, if you have explicitly whitelisted the domain then it's a different story. This is also nothing to do with Windows 7, as it was introduced in IE8 on both XP/Vista/7. There is more info here: https://frankcode.wordpress.com/2013/10/17/a-guide-to-ie-compatibility-view-and-x-ua-compatible/ – Erik Funkenbusch Dec 20 '14 at 01:29
  • Also, there does appear to be a bug in which compatibility view with the x-ua-compatible flag will use the correct document mode, but give the wrong user agent string, which could break webpages that sniff agent string. – Erik Funkenbusch Dec 20 '14 at 01:30
  • the company has some legacy intranet sites that need to use compatibility view. because of that it's not possible to disable the compatibility view for all intranet sites. I'm not really familiar with group policy, but is it possible to make one intranet sites run in compatibility and other not? (Assumming they belong to the same domain) – Daniel W Dec 20 '14 at 01:59
  • Try adding a Mark of the Web (http://msdn.microsoft.com/en-us/ie/ms537628(v=vs.90).aspx) to the web page so that the page is opened in the Internet zone. See if that helps. (I'm not certain, but I believe there was a change in behavior defaults some time between IE8 and IE11.) – Lance Leonard Dec 20 '14 at 06:15