Forcing IE8 to use IE7 Compatibility Mode with IIS Custom Headers

One of the great things about Internet Explorer 8 is that it finally renders, by default, in a standards mode, using web standards instead of Microsoft’s IE tweaks.  It’s also one of the worst things about IE8, for web developers at least.  Developers who have spent countless hours to ensure that their web site renders correctly in all browsers may find that it now renders poorly in IE8.

Fortunately, Microsoft anticipated this and built in a compatibility mode, which allows IE8 to render as if it were IE7 instead.  If a site worked properly in IE7, it will work properly in IE8 running in compatibility mode.  As long as the end user knows enough to change modes of course.  End users often don’t realize what version of a web browser they are using.  And they even more often won’t know how to, or even that you can, change the browser rendering mode.  So it’s up to the developer to ensure they don’t have to.

There are programmatic solutions, meta tags on web pages, code in the web.config and so on, but sometimes it’s just easier to set the entire web site to force IE8 browsers to use IE7 compatibility mode.  You can easily do this with a custom header in IIS.

IIS 7

  1. In IIS7, open IIS Manager, expand the Sites and highlight the site you want to add the custom header to.
  2. In the IIS section of the Web Site Pane, double-click HTTP Response Headers.
  3. When the HTTP Response Headers section opens, click on Add in the Action Pane.
  4. Enter X-UA-Compatible in the Name field.
  5. Enter IE=EmulateIE7 in the Value field.
  6. Click OK to finish, no reboot or IIS restart needed.

IIS 6

  1. In IIS 6, open IIS Manager and right-click the site you want to add the custom header to. 
  2. Choose Properties, then the HTTP Headers tab.
  3. In the Custom HTTP Headers section, click the Add button.
  4. Enter X-UA-Compatible in the Custom header name field.
  5. Enter IE=EmulateIE7 in the Custom header value field.
  6. Click OK until you have exited the Properties dialog, no reboot or IIS restart is needed.

Just remember to remove this custom header from the site when it is finally IE8 compatible.

Disclaimer

As usual, do this at your own risk.  If it doesn’t work, too bad.  You’re on your own to fix it.  If you have changes or suggestions on this, we’d love to see a comment.  You can also find this documented online at http://msdn.microsoft.com/en-us/library/cc817572.aspx, where you’ll also find code to do this in your web.config file.  Thanks to Joe Healy from Microsoft for pointing out the XUA tag at a very opportune time.

Advertisements

3 thoughts on “Forcing IE8 to use IE7 Compatibility Mode with IIS Custom Headers

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s