Scott Hanselman

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

March 21, '12 Comments [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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, March 21, 2012 10:27:57 PM UTC
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 :)
Wednesday, March 21, 2012 10:36:19 PM UTC
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.
Wednesday, March 21, 2012 10:38:11 PM UTC
Ya, Add Browser is a good idea, or maybe "manage browsers" or just "browsers..."
Wednesday, March 21, 2012 11:43:00 PM UTC
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.
Thursday, March 22, 2012 12:04:12 AM UTC
Josh - What if we made a new kind of browser? An app that registered itself as a browser and launched "n" browsers?
Thursday, March 22, 2012 1:36:25 AM UTC
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
Mike
Thursday, March 22, 2012 2:41:32 AM UTC
This page is the best thing on the internet. Thank you.
Erick
Thursday, March 22, 2012 12:38:16 PM UTC
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?
Thursday, March 22, 2012 1:48:49 PM UTC
Is the Browse With dialog accessible from the new Ctrl+Q quick search feature?
Thursday, March 22, 2012 2:36:51 PM UTC
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
Thursday, March 22, 2012 3:05:31 PM UTC
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. ;)
Thursday, March 22, 2012 3:51:09 PM UTC
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.
Mithun
Thursday, March 22, 2012 8:33:40 PM UTC
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?
Thursday, March 22, 2012 8:35:08 PM UTC
Daniel - I agree. I'm working to get it updated.
Saturday, March 24, 2012 1:50:54 PM UTC
Thanks Scott!
Sunday, March 25, 2012 3:21:40 AM UTC
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.
Kevin
Sunday, March 25, 2012 3:54:12 PM UTC
Just curious as I haven't tried the new VS yet, does this issue affect its default browser setting as well?
Monday, October 15, 2012 8:59:15 AM UTC
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.
Stephen Dougherty
Comments are closed.

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