Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Chrome using .net 3.5 and C#

Tags:

c#

asp.net

Okey, I am using this code to detect the browser

<%= Request.Browser.Browser %>

When using chrome, it is giving me browser

AppleMAC-Safari

I need it to say chrome, Ater looking around, i found this

Google Chrome/Safari Same Browser Name and Version !

I did all that was given in the answer to the question, but that doesn't help.

I am using VS 2010 and using .net framework 3.5

thankyou.

Edit: I tried doing what is suggested on this page

http://www.codemonkeez.com/2010/06/detect-google-chrome-browser-with.html

it is still giving me

AppleMAC-Safari

:/

thanks again.

like image 509
Yousuf Jawwad Avatar asked May 19 '11 02:05

Yousuf Jawwad


2 Answers

Have you tried:

if (Request.UserAgent.Contains("Chrome") && !Request.UserAgent.Contains("Edge"))
{
    //do chrome stuff
}
like image 157
Avitus Avatar answered Oct 19 '22 15:10

Avitus


Use <%= Request.UserAgent %> which will give you something like this:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24
like image 2
Achinth Gurkhi Avatar answered Oct 19 '22 16:10

Achinth Gurkhi