Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

determining client browser in codebehind

Posted on 2014-01-22
5
Medium Priority
?
444 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 2000 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 84

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

718 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