Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do i change the 'Document Mode' of IE in web config ?
I have developed a website and it works good in my local. But after publishing, when am trying to open the site i could see some misalignment.i checked the document mode using developer tool it is IE7 standards.When i change it in to IE9 there it works as expected.
Also if i unchecked the compatibility view then also it works as expected.
So i want to know the way to do this in web config.
Posted
Updated 8-Dec-14 0:44am
v2

The problem is with IE.
IE decided that intranet sites are best viewed when compatibility mode is on - so whenever IE identifies an internal web site it turns on compatibility mode (yes I know it's evil)...
You can use X-UA-Compatible in two ways...
1. Add to web.config
XML
<configuration>
  <system.webserver>
    <httpprotocol>
      <customheaders>
        <clear />
        <add name="X-UA-Compatible" value="edge" />
      </customheaders>
    </httpprotocol>
  </system.webserver>
</configuration>

2. Add to page (in which case it must be the first meta-line)
HTML
<html>
  <head>
    <meta http-equiv="x-ua-compatible" content="edge">
  </meta></head>
</html>

The other option is to turn of IE behavior from the menu Tools->Compatibility View Settings...
 
Share this answer
 
Comments
Am Gayathri 8-Dec-14 7:02am    
HiActually i have added the first one already in webconfig. This is working in my local but when i deploy in to IIS6 server it is not working. By default IE document mode is coming as IE7 standards. It doesn't make any changes even if i switch off compatibility mode.
Kornfeld Eliyahu Peter 8-Dec-14 7:08am    
That because IIS6 can't read that config elements...It has a much complicated way to set those properties and I suggest you use the second options for IIS6 (leave the first in for IIS upgrade)...
Am Gayathri 8-Dec-14 7:16am    
So should i add this meta tag in each page or only in master page ?
Kornfeld Eliyahu Peter 8-Dec-14 7:21am    
Better via master...
Am Gayathri 8-Dec-14 7:32am    
In master page, under this <head runat="server"> correct? like
<head runat="server">
<title>My Page</title>
<asp:ContentPlaceHolder ID="head" runat="server">

<link href="CSS/Style.css" rel="stylesheet" />
<meta http-equiv="x-ua-compatible" content="edge">
</meta>
</head>
 
Share this answer
 
Comments
Am Gayathri 8-Dec-14 6:44am    
Will this work in IIS6?
Deepu S Nair 8-Dec-14 6:53am    
gud link.....

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900