Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

determining client browser in codebehind

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?
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

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
Avatar of HLRosenberger

ASKER

paulmacd:   I've already seen these articles.   What I need to know is why, when I'm using IE, does it tell me Mozilla?
ASKER CERTIFIED SOLUTION
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
thanks