6

I need to determine which version of browser the user is using, however compatibility mode is turned on by default for the entire company.

On the server side script, how do I determine the real browser version?

Thanks

Update I've got my page correctly showing the IE version using document.documentMode, however I can't figure out how to pass this over to the server side so I can use it.

Matt
  • 4,140
  • 9
  • 40
  • 64
  • possible duplicate of [Detect IE8 Compatibility Mode](http://stackoverflow.com/questions/1328963/detect-ie8-compatibility-mode) – Michael Haren Jul 18 '11 at 03:59
  • @Michael How do I do that server side though? I use the result as part of a Linq query – Matt Jul 18 '11 at 04:11

4 Answers4

4

Request.Browser will give you complete browser information, where you can check version, browser name, browser type etc.

Request.Browser.Version // Return complete browser version infor
Request.Browser.Browser // If browser is IE then it will return **IE**
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
  • 2
    This doesn't work when the browser is using compatibility mode. Request.Browser.Version returns 7.0 even though I am using IE9. This is what I am trying to get around – Matt Jul 18 '11 at 04:05
  • @Matt Check this [link](http://blogs.msdn.com/b/ie/archive/2009/01/09/the-internet-explorer-8-user-agent-string-updated-edition.aspx) – V4Vendetta Jul 18 '11 at 05:33
2

document.documentMode in javascript was the solution.

<script>
alert(document.documentMode);
<script>
Matt
  • 4,140
  • 9
  • 40
  • 64
0

Use HttpContext.Current.Request.UserAgent on server if on client then user navigator.userAgent and then instructions from below ie7 has no trident keyword but ie8 is trident/4 and IE5 is trident/5.

First look for MSIE x.x, if x.x is 7 then look for Trident/y.y. If trident is missing then it IE7 if y.y is 4 then its IE8 and if y.y is 5 then ie9 and if y.y is 6 then ie10

http://blogs.msdn.com/b/ie/archive/2010/03/23/introducing-ie9-s-user-agent-string.aspx

0

Rather than fighting compatibility mode, you can turn it off for your specific web application. We do this on all of our sites because compatibility mode really screws a lot of things up.

Force IE compatibility mode off using tags

Community
  • 1
  • 1
NotMe
  • 87,343
  • 27
  • 171
  • 245
  • 1
    I had a crack at that, but I couldn't make it work. I'll look into it further though since it is a more elegant version than what i've currently got. – Matt Jul 20 '11 at 05:22