Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

determining client browser in codebehind

Posted on 2014-01-22
5
441 Views
Last Modified: 2014-01-24
I'm trying to determine the  client browser being used, via code on the server.  Is this possible?  I tried these objects: Page.Request.UserAgent and Page.Request.Browser.Browser.  I've read that this is the way to do it.  However, what I see does not make sense to me.  

If the browser is Firefox, Page.Request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0"; Page.Request.Browser.Browser = "Firefox".

If the browser is IE, Page.Request.UserAgent = ""Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"" Page.Request.Browser.Browser = "Mozilla".

How can this be?  What is the correct way to determine the browser?
0
Comment
Question by:HLRosenberger
  • 2
  • 2
5 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 39800493
Here are several bits of sample code.  You may have to tease apart the Agent string to find exactly what you need.

How to: Detect Browser Types and Browser Capabilities in ASP.NET Web Pages:
http://msdn.microsoft.com/library/3yekbd5b

How to determine browser type in server-side code without the BrowserType object in ASP.NET:
http://support.microsoft.com/kb/306576

How to: Detect Browser Types in ASP.NET Web Pages:
http://msdn.microsoft.com/en-us/library/3yekbd5b(v=vs.90).aspx
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 39800525
paulmacd:   I've already seen these articles.   What I need to know is why, when I'm using IE, does it tell me Mozilla?
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39800567
Oh, I see.  IE started identifying itself as Mozilla way back in the day so those websites "optimized for Mozilla" would see IE as Mozilla.


Sources:
http://stackoverflow.com/questions/7975996/why-does-internet-explorer-9-report-mozilla-in-useragent

http://superuser.com/questions/113020/why-does-internet-explorer-call-itself-mozilla

http://en.wikipedia.org/wiki/Mozilla
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39800640
It has always said 'Mozilla'.  Here is a list of the thousands of User Agent Strings that have existed for different browsers.  http://www.useragentstring.com/pages/useragentstring.php
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 39806532
thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question