0

I'm developing an MVC app.

If I (on my Surface Pro) goes to http://www.whatbrowser.org/ it correctly says IE 10.

But if I go to my MVC app and print out the Request.Browser.Version, it returns 7.

Any idea why? Is Request.Browser.Version broken?

Thanks

tereško
  • 58,060
  • 25
  • 98
  • 150
MojoDK
  • 4,410
  • 10
  • 42
  • 80
  • 8
    Everything about browser detection is broken =/. – jeremy Jul 05 '13 at 20:21
  • 2
    From what I've read, IE11 won't even register as IE anymore. – Joe Enos Jul 05 '13 at 20:26
  • Use feature detection, not browser version detection. You really shouldn't care whether the client uses IE version 24. What you should care is whether this particular browser supports the feature you are trying to implement on your website or not. – Darin Dimitrov Jul 05 '13 at 20:47
  • @Darin, yeah but IE < version 9 is not supported on jquery 2.x, so I need to server jquery 1.x to IE < 9 clients and 2.x to 2.x+ clients. – MojoDK Jul 06 '13 at 07:36

2 Answers2

1

Some of this is touched on in Detect Internet explorer browser version problems.

Last I knew Request.Browser uses the *.browser files that come with the installs of ASP.NET, and easily get out of date. Microsoft releases updates to them every so often, but not often enough. Currently there are some issues with webform pages breaking on IE10 without updated browser files.

Like the comments have said, browser detection is very broken. If you need to detect the browser, at the very least shy away from using the user agent string, and seriously consider why you need to know exactly what browser is used.

Community
  • 1
  • 1
Steven V
  • 16,357
  • 3
  • 63
  • 76
0

Request.Browser.Version doesn't always return the 'correct' browser version for IE because of many factors including compatibility view, meta tags etc.

You would be better off detecting browser capabilities instead. Further reading here: http://msdn.microsoft.com/library/3yekbd5b

As a personal preference, it would be best to detect the OS instead of the browser. Most of the common HTML5/CSS3 features are supported in IE9 and above and IE9 requires Windows Vista and up. The best way to do this using the User Agent is by checking the Trident. If there is compatibility view enabled via the browser or by using meta tags by the app itself, the wrong 'version' is returned but the Trident remains correct.

PS. This isn't fool proof but this would work most of the time.

Further reading about Trident here: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#PltToken

reggaemahn
  • 6,272
  • 6
  • 34
  • 59