Scott Hanselman

Extending the Visual Studio 11 Web Browser Chooser and Browse With Menu to include Developer Profiles

March 22, 2012 Comment on this post [18] Posted in ASP.NET | ASP.NET MVC
Sponsored By

I talked about some new features that have snuck made their way into the free version of Visual Studio for Web. One of the more useful ones is the Browser Chooser that allows you to quickly launch debug sessions with different browsers from within VS. I've actually been pushing on this for about 18 months, and even blogged about it in August of 2010 in "how to change the default browser in Visual Studio programmatically with PowerShell and possibly poke yourself in the eye."

In Visual Studio 11 Beta you get a nice dropdown with all the browsers (plus the new Page Inspector).

Browser Switcher built into the toolbar

However, I got a good comment from blog reader Abhijit who said:

The browser is a welcome addition (though past versions of VS do something similar). I'd like to make one suggestion though.
I use multiple Firefox and Google Chrome profiles. One for regular browsing and another for web development/debugging.
For ex: To launch a profile named 'dev' in Firefox, you'd use
firefox -p dev --no-remote in the shortcut/command line
This ensures that I don't mess up my history/profile/cookies etc with my development activities. However, the feature you've described launches the browser with no command line parameters.
So, is there a way I can add/update/customize the parameters used to launch the different browsers? And if not, is too late to suggest this as a feature request for VS11?

This is a not only a great tip, but a very useful bug/feature request. The tip is to use different profiles for when developing so you aren't accidentally combining your history and cookies for development with your personal stuff.

The feature is interesting because he wants to know how to customize the Browser Chooser. Digging into it, it turns out that it's totally possible but totally not discoverable. That means there's an opportunity to make this feature WAY WAY more useful.

First, here's the way to change it today on the Beta. Then I'll suggest a possible change to the feature to make it easier.

That list is initially auto-populated with the browsers we find on your system. You can add to the list with the "Browse With..." menu that you get when you right click on an .ASPX file in Visual Studio. Ah! But there's where the trouble starts. You can currently only see that menu when you right click on an ASPX page. This is great for Web Forms folks, but if you don't have an .ASPX file in your project then you're out of luck.

So, for now, add an ASPX file (you can delete it later) and right click:

Browse With is only visible when right-clicking on an ASPX file

That brings you to the list of browsers in the Browse With dialog:

All your browsers listed in the Browse With dialog

At this point you can add your dev profile browser. (It would be nice if you could edit also, but you can't today.) Here I'm adding Firefox with a "dev" profile. Note that I'm naming it differently from existing browsers.

Adding a Firefox Dev Profile with "firefox.exe -p dev"

Here's my updated Browse With using the new Firefox dev profile. You could do with this Chrome also if you like.

Browse With showing my new Firefox Dev Profile

Now my browser chooser menu in the toolbar is updated with the my new browser. You can put whatever you like in that menu.

Menu in VS dropped down showing my new Firefox Dev Profile

Ok that's today with the Visual Studio 11 Beta. Here's a Paint.NET proposal of what I'd like to see. It'd be nice for the "Browse With..." to appear inline in the drop down menu. Having in the Right Click menu is too confusing.

MOCKUP - Browse With Proposal with added menu - photoshop

This is just a Paint.NET but you get the idea. Thoughts?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
March 22, 2012 2:27
THIS. It would be my favorite option in VS2011. I am actually willing to forget about the gray UI if they implement this in the RTW :)
March 22, 2012 2:36
That's actually a really cool addition to VS 11 that I wasn't aware of (haven't jumped on the Beta yet). And I think that your suggested solution is genius: non-invasive, simple yet powerful. The only suggestion I could make would be to replace the text "Browse with..." with "Add browser...", yet pop the same dialog. For some reason "Browse with" just seems out of place as a command name for this specific scenario, whereas "Add browser" seems more straightforward as to what the action will actually do. Know what I mean? But that's just nit-picking.
March 22, 2012 2:38
Ya, Add Browser is a good idea, or maybe "manage browsers" or just "browsers..."
March 22, 2012 3:43
Awesome post, Scott. Wondering if you could write an update that would explain how to have VS11 use a batch file that fires multiple browsers at the same time for cross-browser debugging?

I've been messing with it over the last couple of days and have only found how to select multiple browsers in the Browse With dialog. That's OK, but would love it to be a single keyboard shortcut.
March 22, 2012 4:04
Josh - What if we made a new kind of browser? An app that registered itself as a browser and launched "n" browsers?
March 22, 2012 5:36
Josh, If your using IIS or IIS express you could alternatively use the url in the second browser and hit refresh. 1 extra click... would it not seem kind of redundant popping up 2 windows? This would seem to be more benificial for a designer maybe? Jquery pitch here
March 22, 2012 6:41
This page is the best thing on the internet. Thank you.
March 22, 2012 16:38
Along the same lines, one tiny annoyance of VS2010 when working with Firefox or Chrome is that the debugger continues to run after you close the browser. If you close IE, the debugger automatically detaches. Any change VS11 will detach when the 'other' browsers are closed?
March 22, 2012 17:48
Is the Browse With dialog accessible from the new Ctrl+Q quick search feature?
March 22, 2012 18:36
Regarding Josh's question. Here's a batch file that you could set as the "browser"

START "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" %1

START "" C:\%HOMEPATH%\AppData\Local\Google\Chrome\Application\chrome.exe %1

START "" "C:\Program Files (x86)\Internet Explorer\iexplore.exe" %1
March 22, 2012 19:05
Thanks Joel! Works like a charm. Added Safari and now all four browsers open simultaneously.

And yes, Mike, I needed this because I am a designer/front-end dev. ;)
March 22, 2012 19:51
Very cool. i have observed that when i work on my .net 4 ASP.Net MVC 3 app in VS11 the number of script tags has drastically reduced and it also has been rearranged. I go back to VS10 and it looks just fine. Guessing it is trying to optimize some stuff but some script tags are totally missing.
March 23, 2012 0:33
I don't understand how this lack occured. They designed such a nice way to change your default browser, but missing an easy way to manage the list?
March 23, 2012 0:35
Daniel - I agree. I'm working to get it updated.
March 24, 2012 17:50
Thanks Scott!
March 25, 2012 7:21
It would be nice to have an OK button on the Browse With dialog.

A minor annoyance since the Browse With... option has been available on the context menu in the Solution Explorer has been that you have to click the Browse button to get your settings in the dialog to stick. If you click Cancel, any browsers or default setting gets discarded (as it should be). But that means you always have to browse (read: run without debugging) with the new browser settings to get them to stick, then you can close the page and return to VS to start debugging.

Since the use case for the new browser drop-down is to debug, not browse, it would be nice to have an OK button on the dialog in order to add your browser(s), close the dialog, then immediately choose the browser with which you want to debug the web app.

Also, it seems that a simple addition like an OK button to the existing dialog, and just adding a menu option to access the existing dialog from the new browser drop-down in VS11, would be more likely to get implemented than a new "Add Browsers..." or "Browsers..." option, since the Browse With dialog has existed for some time, and would continue to work for both the browser drop-down and the Solution Explorer use cases.
March 25, 2012 19:54
Just curious as I haven't tried the new VS yet, does this issue affect its default browser setting as well?
October 15, 2012 12:59
Not sure if I have my multiple Firefox profiles set up wrongly in Firefox as when I stop debugging the Firefox dev profile stays open and when I try to debug again I am giving the message, "Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system."

Can anyone confirm similar behavior? Ideally I would like Firefox to close the Dev window after I stop debugging similar to IE.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.