ASP.net (IIS): IE8 - Compatibility view
February 10, 2011 by
Internet explorer 8 adheres to industry standards (W3C) a lot more than previous versions
of the browser - unfortunately it comes with a price (e.g. with regards to how IE renders
Microsoft did however think about this problem and introduced what they call "compatibility view",
basically we've got a toggle button in the browser, like seen in the following image:
When we press the button, the site renders using the IE7 engine (solving our immediate problem).
It would however make a lot more sense if the visitor of the website didn't need to press the
button, for that reason we can put the following meta tag into our website.
Note that this tag needs to appear before any other element inside the html page's head tag (except the
title and other meta tags, else the browser will simply ignore it)
, you will notice the
"compatibility view" button disappearing - the visitor can't disable compatibility.
I did however see an interesting issue while settings emulation on one of our ASP.NET projects -
since we've got a server side head tag, it won't necessarily be possible to always place the
meta tag we're its supposed to be.
We can luckily additionally set compatibility via the web.config like this:
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
This causes IIS to automatically pass emulation via HTTP response header across all pages.