asp.netinternet-explorerie-compatibility-mode

How to differentiate between ie7 and IE compatibility on higher versions on the server


Is it possible to differentiate between request coming from IE7 and request coming from higher version of IE running in compatibility mode?

I would prefer a pure server side solution to something involving JavaScript.


Solution

  • Check user agent for IE version and Trident version, like in this article:

    string userAgent = Request.UserAgent; //entire UA string
    string browser = Request.Browser.Type; //Browser name and Major Version #
    
    if (userAgent.Contains("Trident/5.0")) //IE9 has this token
    {
        if (browser == "IE7")
        {
            mode = "IE9 Compatibility View";
        }
        else
        {
            mode = "IE9 Standard";
        }
    }