18

I am using the Flot plotting library. It seems to work fine in IE8 and IE9 but the problem comes when in IE9 Compatibility View - it does not render any of the graphs. I suspect this is because of the HTML5 canvas object it uses heavily but I could be wrong. I tried doing the following:

  • Add: <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> to my HTML <head></head> tag. I even tried IE=8 and IE=9 and that did not help either. My tag look like this:

    <!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>
    
  • Because I was still seeing the problem, I added the following to my Global.asax.cs file:

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown
        Response.Headers.Add("X-UA-Compatible", "IE=Edge");
    }
    

I am still facing the problem. The error I get is this:

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

Is there anyway to over ride this?

EDIT: Checking my response headers, adding that line in Global.asax.cs did not add them to my headers. I wonder why.

Response Headers:

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

EDIT 2: Apparently, Application_End was the wrong event. Instead, doing this injected the element into the header:

void Application_BeginRequest(object sender, EventArgs e)
{
    Response.Headers.Add("X-UA-Compatible", "IE=Edge");
}

But the problem itself still persists.

Legend
  • 113,822
  • 119
  • 272
  • 400
  • 1
    did you try adding it as the first tag after ``? IE only seems to respond to this when it occurs first in the list of meta tags. – SliverNinja - MSFT Oct 27 '11 at 20:36
  • @SliverNinja: Yes. I have it as my first tag. Also updated my question with the exact markup I am using. – Legend Oct 27 '11 at 20:38
  • Should work then according to popular feedback here (http://stackoverflow.com/questions/637039/how-to-avoid-ie8-compatibility-button). – SliverNinja - MSFT Oct 27 '11 at 20:43
  • Is there a reason why you add the response header in the Application_End method? Shouldn't that be in the Application_BeginRequest method instead? – Chris Oct 27 '11 at 20:44
  • Application_End is not the right event. Try `PreSendRequestHeaders` (http://msdn.microsoft.com/en-us/library/system.web.httpapplication.presendrequestheaders) – SliverNinja - MSFT Oct 27 '11 at 20:46
  • @Chris: That is because in the `Application_Start` method, the `Response` object would not be available for use yet. – Legend Oct 27 '11 at 20:46
  • @Legend: Yeah, I meant Application_BeginRequest. Application_End fires when the application is closing... Which wouldn't do anything for Requests happening during the execution of the application. – Chris Oct 27 '11 at 20:48
  • @Chris: You were right. Adding it to `Application_BeginRequest`, I am not able to see the headers on the client side but the problem still persists :( – Legend Oct 27 '11 at 20:52
  • @SliverNinja: Adding it in `Application_BeginRequest` injected the element into the header but the problem still persists. – Legend Oct 27 '11 at 20:52

4 Answers4

33

The problem may be due to your Internet Explorer compatibility view settings. If you go to the "Tools" menu, then to "Compatibility View Settings", make sure that "Display intranet sites in Compatibility View" is not checked. You may be seeing IE force you into compatibility view based on your hostname being detected as being in your intranet.

Note that - depending on your version of IE - you might have to press the left Alt key for the menubar to appear, from where the "Tools" menu can be opened.

zb226
  • 9,586
  • 6
  • 49
  • 79
Jacob
  • 77,566
  • 24
  • 149
  • 228
  • Yes. That is indeed the case. While I can change this for myself, I am trying to override this setting (though I am not it makes much sense). I am not even able to detect this mode because this check: `if ($.browser.msie && parseInt($.browser.version) != 9) {alert("Not IE9!"}` does not catch the fact that IE9 is in Compatibility mode. – Legend Oct 27 '11 at 21:32
  • 1
    I don't think you can override that compatibility setting. See the comments on http://stackoverflow.com/questions/3726357/why-does-ie9-switch-to-compatibility-mode-on-my-website/3726605#3726605. – Jacob Oct 27 '11 at 22:29
  • 1
    If you are running locally make sure you spoof a 'live looking' URL through your hostfile and it will think the site is an internet site. – sidonaldson Nov 27 '12 at 11:15
  • 5
    Because that's exactly what a web developer working in /localhost/ wants to do - to view his or her work in IE7 emulation by default. Bravo, Microsoft. Carry on eating glue. – Imperative Dec 18 '14 at 21:36
  • http://teelahti.fi/blog/disable-internet-explorer-compatibility-view-via-web-config This is a very helpful tip that solved my Internal server Compatibility problem. I tried all of your solutions before that. – GeorgiG Aug 18 '16 at 10:29
3

You can set compatibility settings directly on IIS. If you click on the site and open up Response Headers you can add X-UA-Compatible with a value of IE=X, where X is your target version. You can set this at the server level as well. But keep in mind if you have multiple sites on the same box you might experience issues with those. Altough you could apply at the server level and then delete the inherited config from the site level.

Alex Nelson
  • 1,182
  • 9
  • 19
  • 1
    This cannot override IE thinking the site is an intranet site! – sidonaldson Nov 27 '12 at 11:14
  • 1
    This worked for me. I'm using IIS Express locally to develop a site with JQuery 2. It is not compatible with the IE 7 mode that IE 10 seems to default to for the local site. Open up the config file %UserProfile%\My Documents\IISExpress\config\applicationhost.config and . See http://msdn.microsoft.com/en-us/library/jj676913(v=vs.85).aspx – Cameron Taggart May 26 '13 at 17:29
2

Two years, and two new editions of IE later, and this IE8 issue is still causing problems !

I found that, for our company's ASP.Net app, adding the "X-UA-Compatible" in the web.config, in the webpages, or their code behind, made absolutely no difference.

The only thing that worked for us was manually unticking the "Display intranet sets in Compatibility View" checkbox:

Turn off Display intranet sets in Compatibility View

Mike Gledhill
  • 27,846
  • 7
  • 149
  • 159
0

The weird thing is - if you delete the runat="server", the meta tag will work and the button will disappear. BNut of course it's not recommended to delete the runat.

Kevin Panko
  • 8,356
  • 19
  • 50
  • 61
Oshrib
  • 1,789
  • 12
  • 40
  • 67