Tuesday, November 30, 2010

IE8 wrong style rendering on IIS / ASP.Net Dev server

I've ran into issues when site renders perfectly in VS's ASP.Net Dev Server on IE8, but when published to IIS, some styles are messed up. To make it even more confusing, it renders correctly when displayed locally on the web server and incorrectly when accessed from different machine.
Apparently I'm not the only one having this issue - and the solution is simple. Let IE know that the page should be rendered in correct mode.

Solution 1 - add following to the 'head' tag of the page:
<meta http-equiv="X-UA-Compatible" content="IE=8" />

Solution 2 - add this section to the web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>

The detailed description from Microsoft is here.