Detecting IE11 with C#
browser, c#
Solution
Yes the user agent has changed to this:
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko
Most important part here is the removal of MSIE token and addition of like Gecko. This means that Internet Explorer would prefer to be identified as a Gecko-type browser if it’s not identified as itself (so the old IE hacks will not be applied to it). If you want to identify it as IE than you must look for Trident token and the version comes via rv token.
Now all of the above should be taken into consideration only if you need to examine the user agent at the server side for some reason. For using JavaScript fallbacks, HTML5 polyfills etc. you should be checking if given functionality is supported in the code on the client side (there are libraries which help with that like for example Modernizr).
Problem
Before loading a webpage I am detecting browser and version to determine compatibility. So if the browser is less than IE7 I display an incompatible message. Testing the webpage in IE11 my webpage is displaying the incompatible message. I'm currently getting the browser name from: ``` var browser = Request.Browser.Browser; ``` and the version from ``` var version = Request.Browser.Version; ``` I then check that the browser is IE and the version >= 7. I believe that the user agent has changed for IE11. So what is the best way to detect if the browser is >= IE7 using C#. EDIT: Request.Browser.Browser returns the browser name, e.g. IE. Request.Browser.Version returns the version number. I add these to a BrowserVersion object I have and compare these values to an array of supported browser versions that I have also. i.e. ``` private static List<BrowserVersion> m_supportedBrowsers = new List<BrowserVersion>() { new BrowserVersion("IE", 7), new BrowserVersion("Firefox", 3), new BrowserVersion("AppleMAC-Safari", 5), new BrowserVersion("Safari", 5) }; ``` where BrowserVersion is just an object that has 2 string properties (name and version).