DCSIMG
July 2009 - Posts - A Bit Lighter

A Bit Lighter

Simple things that may help you

July 2009 - Posts

Detecting IE8 on server side

If you want to know the type of the client browser, you will probably check the Request.Browser.Type property. However, you will notice that IE8 is reported as IE7. There is a simple work around for this. If you check the Request.UserAgent property, you will see that IE8 browsers insert word “Trident”. So this code solves the problem:

string browserType = Request.Browser.Type;
// IE8 is not reported in browser type but it can be detected 
// by word "Trident" in the user agent
if (Request.UserAgent.ToUpper().Contains("TRIDENT"))
    browserType = browserType.Replace("IE7", "IE8");