Emulate IE7 header insertion in response for IE8

Problem this snippet solves:

Insert an HTTP header in responses to Internet Explorer 8 clients which tells the client to emulate Internet Explorer 7 when rendering the web application content.

earton wrote in this post:

http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=56407&view=topic

With the release of IE8 yesterday, I need to be able to automatically make users who have IE8 installed to be forced into an IE7 compatible mode. I have read some articles on Microsoft that details doing this by the use of the following commands

< ?xml version="1.0" encoding="utf-8"?>
< configuration>
< system.webServer>
< httpProtocol>
< customHeaders>
< clear />
< add name="X-UA-Compatible" value="IE=EmulateIE7" />
< /customHeaders>
 
< /system.webServer>
< /configuration>

Is it possible to do the same thing in an iRule when a client connects to a virtual server which hosts IIS servers.

Joe provided the suggestion of using an iRule to insert the corresponding HTTP header in the response. Here is an example which implements this functionality.

Code :

when HTTP_REQUEST { 

   # Check if User-Agent header is IE 8 
   if { [HTTP::header User-Agent] contains "MSIE 8" } { 
      set IE8Resp 1 
   } else  { 
      set IE8Resp 0 
   } 
} 
when HTTP_RESPONSE { 

   if { $IE8Resp } { 

      log local0. "[IP::client_addr]:[TCP::client_port] Inserting X-UA-Compatible: IE=EmulateIE7 header" 
      HTTP::header insert "X-UA-Compatible" "IE=EmulateIE7" 
   } 
}
Published Mar 17, 2015
Version 1.0

Was this article helpful?

1 Comment

  • This one doesn't work. I tried the below code without any if statements:

     

    when HTTP_REQUEST {

    HTTP::header remove "X-UA-Compatible"

    HTTP::header insert "X-UA-Compatible" "IE=11.0"

    }

    when HTTP_RESPONSE {

    HTTP::header remove "X-UA-Compatible"

    HTTP::header insert "X-UA-Compatible" "IE=11.0"

    set user_agent [HTTP::header "X-UA-Compatible"]

    log local0. "User agent value is $user_agent"

    }

    My problem is - I have a website which works externally well on all browsers and internally on all except IE. It's trying to emulate website using version IE7 and giving warning popup message about IE compatibility.

     

    I need to force the HTTP Response to the internal users to use IE11.