0

I support an ASP.NET MVC site that redirects users to an error page if they are on IE7 or earlier.

if (Request.Browser.Browser == "IE" && Request.Browser.MajorVersion <= 7)
{
    return RedirectToAction("Browser","Error");
}

I now need to make a change to redirect users to an error page if they are using IE10 or earlier. I know that to detect IE8 I would simply need to check MajorVersion equal to 8, but I haven't been able to find documentation on using Request.Browser to detect IE9 and IE10.

Perhaps checking for MajorVersion being less than or equal to 10 is sufficient. However, I know for IE11, Request.Browser.Browser returns "InternetExplorer" rather than "IE", and I haven't been able to locate a definitive answer on what IE9 and 10 return for Browser. Also, with the trust issues IE has given me I don't feel safe assuming IE9 and 10 will set MajorVersion to 9 and 10. Does anyone know for certain what Request.Browser.Browser and Request.MajorVersion will contain for IE9 and 10?

Isaac
  • 277
  • 4
  • 17

2 Answers2

0

I can confirm that Request.Browser.Browser is "IE" and Request.Browser.MajorVersion is 9 and 10, respectively, for the IE 9 and 10 user agent strings that IE 11 uses when you tell it to emulate those earlier versions. Whether that's comprehensive or not, I don't know, and of course user agent strings are inherently untrustworthy since they are easily tamperable.

ejohnson
  • 655
  • 7
  • 18
0

Request.Browser info is from the browser files under [Framework root\Config\Browsers. They are outdated. Try to parse the UA string based on this link.

mattfei
  • 498
  • 3
  • 5