Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB9.0 C# VB VB10.0 VB.NET
Is there a fairly easy way to detect what browsers a user has on their computer? (eg: IE, Chrome, Firefox, Safari, Opera...) I would imagine that you would look in the Registry for part of the process... any other places I would look?
Posted 1-Mar-11 6:17am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Executable files can be placed anywhere, so searching in Program Files is probably not going to work all the time. And the registry is iffy: even if you know where major browsers currently store data, there is no guarantee that future versions will put data in the same location, or that browsers not on your find list are in the same vicinity, or even that the the browser is still installed.
 
So no. To the best of my knowledge, the closest you could get would be to try opening an .html file and try to catch the user's default browser. Assuming they haven't changed it (accidentally or deliberately) to something like Notepad.
  Permalink  
Comments
drummerboy0511 at 1-Mar-11 11:39am
   
Thanks for the heads-up; I knew the Program Files thing wouldn't work. I could probably do a search for "firefox.exe," but who's to say that would work?
 
I could probably just detect the fairly recent versions of the browser in the Registry, and update it as necessary, I guess. It's a small fix, for now at least...
SAKryukov at 1-Mar-11 12:07pm
   
Your first paragraph is correct, but last paragraph makes no sense. Default browser does not matter in any case, because nothing prevents the user to run non-default one. OP wants to know "Browsers" not "Browser". I argue it makes no sense though, please see my Answer.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You cannot do it in principle in any sensible way, simply because the very notion "a user has" is something uncertain. A browser, like any other application can work even if it is not installed. The user can run anything from, say, flash drive at any moment. Most likely, it also makes no sense.
 
You Web application is different story; you can always get some information in the Browser in both client and server parts. Of course, one browser can mimic another one (and some do).
 
If you share your idea, why you want it, you could get better advice. I think your problem is in this idea.
 
—SA
  Permalink  
Comments
drummerboy0511 at 1-Mar-11 12:17pm
   
Okay, why I want it: Part of a program I'm writing has features that only enable if they have a certain browser. If they don't, they can't access it. So, obviously, I need to check, "Okay, do they have Firefox? Okay, then we'll get them in this part. Do they have Chrome? No? Okay, block that."
SAKryukov at 1-Mar-11 14:21pm
   
No, it doesn't explains things yet. If this is Web application, you don't have access to client's computer in principle. Is it is not, it does not matter (for example, you could use embedded browser control which is under your control, also, using Web technology in non-Web application is questionable). Even on local computer you never know what browser will be used in next minute, so your whole idea won't work (even though you did not completely explain the purpose). In all cases, the only valid browser information can be get only after a Web browser already loaded your page, not sooner.
--SA
drummerboy0511 at 1-Mar-11 14:33pm
   
Sorry... it's a desktop application.
SAKryukov at 1-Mar-11 14:47pm
   
Ok, if this is a desktop, you don't need to know all that (especially when you can't :-).
1) You can go along without any Browser.
2) You can enforce Microsoft (or Mozilla, for that matter): embed a Windows Explorer control in your application and use it.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

May be
 
switch (Request.Browser.Browser.ToLower())
{
    case "ie":
       ..
       // your code for IE
       ..
    break;
    case "firefox":
       ..
       // your code for Firefox
       ..
    break;
    default:
       ..
       // default code for other browsers
       ..
    break;
}
 

is what you are looking for.
 


Please vote and mark as answer if this helps you


  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 400
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 1 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100