Click here to Skip to main content
11,492,279 members (61,340 online)
Click here to Skip to main content

Enable Compatibility mode in IE

, 25 Feb 2014 CPOL 41.5K 14
Rate this:
Please Sign up or sign in to vote.
Enable Compatibility mode in IE through code in ASP.NET MVC/HTML meta tag.

Introduction

As there are new releases of IE (Internet Explorer) coming out regularly with new features and functionalities, it is not required for legacy page/site to support latest version of the browser. So, for this reason compatibility mode is been introduced in IE8 onwards.

Problem

I have an ASP.NET MVC web application, I want it to run in IE8 or IE9 compatibility mode in IE10 as our client uses only IE8 or IE9 and we have IE10 in our work stations. Let's see how can we achieve this.

Solution

We can achieve this by setting the value of the compatibility mode.

Web page can specify compatibility mode either by using META tag or by setting the HTTP header, note that META tag will take precedence over http header when both are present.

Sol 1: META Tag- place the following code in head element of web page (HTML page). 

 <meta http-equiv="X-UA-Compatible" content="IE=8, IE=9"/> 

It is not only applicable for IE but also for other browsers like Chrome:

<meta http-equiv="X-UA-Compatible" content="IE=8, IE=9, chrome=1"/>

Important to Note: META tag should be placed in head section before any script or CSS tag.

Sol 2: HTTP Header- We can configure our server to send a HTTP Header along with each page i.e., send X-UA-Compatibility: IE=8 HTTP header

Now, how do we achieve the same in ASP.NET MVC application?

Add the following code snippet in web.config file:

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <clear/>
            <add name="X-UA-Compatible" value="IE=8"/>
        </customHeaders>
    </httpProtocol>
<system.webServer>

Important to Note:

  • system.webServer tag will only be effective if your MVC3 is to run on IIS7 or later
  • If you find your <meta> tag is overridden by IE's intranet settings, this webServer setting will override the compatibility.

For more details browser compatibility mode click here also refer this 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Murali Gowda
Software Developer (Senior)
India India
Yet to be written
Follow on   Twitter

Comments and Discussions

 
QuestionTurn off compatibility mode Pin
DBLWizard25-Jun-14 13:06
memberDBLWizard25-Jun-14 13:06 
AnswerRe: Turn off compatibility mode Pin
Murali Gowda25-Jun-14 21:11
professionalMurali Gowda25-Jun-14 21:11 
GeneralMy vote of 5 Pin
Dipty Ranjan24-May-14 4:05
memberDipty Ranjan24-May-14 4:05 
QuestionHow to make site compatible to IE11 Pin
amit_8321-Feb-14 18:50
memberamit_8321-Feb-14 18:50 
AnswerRe: How to make site compatible to IE11 Pin
Murali Gowda23-Feb-14 20:26
professionalMurali Gowda23-Feb-14 20:26 
QuestionReportViewer now working with IE11 Pin
Mr_T3-Dec-13 0:11
memberMr_T3-Dec-13 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 25 Feb 2014
Article Copyright 2013 by Murali Gowda
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid