Solved

determining client browser in codebehind

Posted on 2014-01-22
5
442 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
[X]
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
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Crystal reports login after closing form 3 37
Access/Visual Basic Question 3 43
asp web application 3 43
VB.NET Inline If statement 4 41
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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