Quick Tip: Stopping a browser from opening when you run a web project in Visual Studio

This one is embarassing. It's something that's annoyed me for years whenever I'm working in a multi-solution/multi-project setup wtih one project for the API and another for the Web UI, e.g. a Web API project in Visual Studio being consumed by an AngularJS project in Visual Studio Code), every time I hit F5 / start debugging the Visual Studio project, pop another tab or browser instance appears that does nothing other than get in the way.

Oh, and I have to remember not to close it. That's the most annoying bit. The clutter, closely followed by the frustration when I accidentally close the browser and stop the debugging session for the Web API project.

It's embarassing because the solution to this has been in Visual Studio for who knows how long (I'm going to take a guess that the answer is probably for ever!) in the Web tab of Project Properties:

The Web tab of a projects properties, showing the 'Don't open a page. Wait for a request from an external application' option

The answer is the last option in the screengrab, "Don't open a page. Wait for a request from an external application". With this selected, the browser won't be opened, perfect for a Web API project. The only negative is that this option appears to be stored in the .csproj.user file for the project, rather than the .csproj file, meaning that it's a per-user setting.

Still, even with that minor caveat, I wish I'd actually taken the time to look and see what's present in Web project properties before!

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments