Browser Detection for Smart Browsers

Does anyone know how to differentiating between Chrome and Safari in asp.net 3.5?

The user agent returns the rendering engine as Apple Web Kit for both browsers.
fsbptAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

APoPhySptCommented:
hi,

Have you tried:

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



cheers
0
fsbptAuthor Commented:
Yes, it doesn't matter.  The following is returned using Request.Broswer for either of them.

Browser: "AppleMAC-Safari"

Below are user agent server variables.

Chrome:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36

Safari:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
0
APoPhySptCommented:
so the code I suggested should work.

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

Open in new window


this will search the UserAgent String for the word 'Chrome', and the safari one does not contain the word 'chrome', but the Chrome one does.
0
Managing Security Policy in a Changing Environment

The enterprise network environment is evolving rapidly as companies extend their physical data centers to embrace cloud computing and software-defined networking. This new reality means that the challenge of managing the security policy is much more dynamic and complex.

fsbptAuthor Commented:
That would be true if I were only looking for Chrome.  However, I'm trying to determine if a browser is Safari.
0
Rose BabuSenior Team ManagerCommented:
Hi Have a look on the below link

http://msdn.microsoft.com/en-us/library/3yekbd5b(v=vs.90)

String BrowserName = Request.Browser.Browser.ToString();

Open in new window

The above line of code will give you the browser name.

It is working and tested in IE,Chrome,FF,Safari,Opera. Try like this.
0
fsbptAuthor Commented:
I figured out the best way to do is to have 2 configuration keys (permitted, prohibited browsers) and compare the user agent strings.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.