Override X-UA-Compatible setting in web.config for specific pages and frames

14,064

Solution 1

I finally got this fixed by putting this code in the Page_Load() of every page that is part of the frameset for this page (about a dozen pages in total).

Response.ClearHeaders();
Response.AddHeader("X-UA-Compatible", "IE=5");

I had been assuming that the frameset pages would inherit the setting from the main page, but apparently not. Just putting that on the main page did not work, I had to put it on every page/frame.

Solution 2

You could try using a location tag...

<location path="YourPage.aspx">
    <system.webServer>
       <httpProtocol>
          <customHeaders>
             <add name="X-UA-Compatible" value="IE=5" />
          </customHeaders>
       </httpProtocol>
    </system.webServer>
</location>
Share:
14,064
xcer
Author by

xcer

Updated on June 27, 2022

Comments

  • xcer
    xcer almost 2 years

    I have a .Net web application that includes a web.config setting to force Internet Explorer to turn off compatibility mode and use the most recent version of IE available:

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

    However, this application contains a legacy page that requires Compatibility mode. In my testing, it will only display properly when X-UA-Compatible is set to IE=5.

    Is there a way to override the web.config setting for a single page?

    Among the many things I have tried that have not worked:

    • Including <meta http-equiv="X-UA-Compatible" content="IE=5" /> on the page itself, as the first tag after <head>
    • Adding X-UA-Compatible:IE=5 to the response headers. Unfortunately, it also sends the X-UA-Compatible:IE=Edge header, and that one 'wins.'
    • Changing the <!DOCTYPE >. I tried all the various options.
    • Adding a comment before the DOCTYPE
    • Re-writing the page to be standards-compliant. This is obviously the best solution, but the page in question is a complex mapping application, and the re-write is going to take several months.

    Update
    When I called this "a complex mapping application," I should have said "a rat's nest of frames and tables." It turns out that the frames part was relevant to the solution.