1

I need to register the browser that the user is using.
I'm using Request.Browser.Type according this question.

However, in my case it is returning this:

Opera             'Chrome54'
Edge              'Chrome54'
Chrome            'Chrome54'
IE11              'InternetExplorer11'
Safari            'Safari5'
Firefox           'Firefox50'


How to find out if the browser is Opera, Edge or Chrome?

Community
  • 1
  • 1
Alexandre Neukirchen
  • 2,713
  • 7
  • 26
  • 36
  • The answer is right in the link that you shared. Use .Contains("Firefox") or .Contains("Chrome"). Or you could remove the numbers with Regex.Replace(browser, "[0-9]", "") – Verkade89 Nov 28 '16 at 13:06
  • 2
    @Verkade89 look at the returns for Opera and Edge. Have you tried `Request.UserAgent` ? Can you fix it by js? look at this [post](http://stackoverflow.com/questions/209043/browser-version-in-prototype-library) – Kiogara Nov 28 '16 at 13:10
  • When I navigate with Opera return false .Contains("Opera") == false – Alexandre Neukirchen Nov 28 '16 at 13:10
  • @Pernambuco You're right, and I am blind. Try using System.Web.HttpBrowserCapabilities browser = Request.Browser; as also mentioned in the link. See all the variables that browser can give, maybe there is something you can identify Opera or Edge. If that doesn't work, then you might be out of options. I have a feeling those browsers use some library (Javascript?) that comes from Chrome. – Verkade89 Nov 28 '16 at 13:14
  • 1
    What if you used Request.Browser.Browser property instead of Request.Browser.Type? – jambonick Nov 28 '16 at 13:14
  • Any time you find yourself doing browser detection, you know that your solution is wrong and you should rethink it. – Cody Gray - on strike Nov 28 '16 at 13:17
  • 1
    @CodyGray What if your task is to detect which percentage of your users uses which browser? – Bart van Nierop Nov 28 '16 at 13:20
  • @Cody Gray, why down vote? – Alexandre Neukirchen Nov 28 '16 at 13:25
  • We have a multi user system, where each is located in multiple browsers, and we are implementing a rule to force it to exit the system when logged in to different browsers. – Alexandre Neukirchen Nov 28 '16 at 13:26
  • Perfectly @Bart van Nierop, this is not the case but it could be. – Alexandre Neukirchen Nov 28 '16 at 13:29
  • @jambonick `Request.Browser.Browser` in _Chrome_, _Opera_ and _Edge_ are the same `Chrome` – Alexandre Neukirchen Dec 04 '16 at 22:18

0 Answers0