Yousuf Jawwad
Yousuf Jawwad

Reputation: 3097

Detecting Chrome using .net 3.5 and C#

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.

Upvotes: 5

Views: 9533

Answers (4)

Avitus
Avitus

Reputation: 15958

Have you tried:

if (Request.UserAgent.Contains("Chrome") && !Request.UserAgent.Contains("Edge"))
{
    //do chrome stuff
}

Upvotes: 14

Amir Md Amiruzzaman
Amir Md Amiruzzaman

Reputation: 2079

Try this

<div>
Your browser is: <%=Request.Browser.Browser %>
</div>

Upvotes: 1

Achinth Gurkhi
Achinth Gurkhi

Reputation: 2156

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

Upvotes: 2

John Saunders
John Saunders

Reputation: 161773

Note that Chrome didn't exist back in 2005, when Visual Studio 2005 was released.

Upvotes: 1

Related Questions