460

I already have a window open with the web site I'm debugging. I don't need VS to launch another one for me every time I need to debug.

Is there a way to stop this behavior?

3
  • Do you have tabbed browsing enabled?.. And are you using IE? Apr 4, 2009 at 4:21
  • You want to disable the Browser Link Feature
    – efkah
    Jul 13, 2020 at 9:12
  • changed for VS 2022. Launch profiles
    – Irf
    Oct 4, 2022 at 9:24

21 Answers 21

483

Open your startup project's properties (Project → {ProjectName} Properties... from the main menu or right click your project in the Solution Explorer and choose Properties), then navigate to the Web tab and under Start Action choose Don't open a page. Wait for a request from an external application.

You will still be able to use any browser (or Fiddler, whatever) to access the running application, but it won't open the browser window automatically, it'll just start in the background and wait for any requests.

12
  • 10
    It does. I use it for debugging all the time. You must have wrong configuration. Double check that you have debugging enabled in the web.config and that you're running a Debug build. Apr 5, 2009 at 16:17
  • 2
    @mjohnsonengr I'd swear this is a per user setting that is local... Perhaps you have .csproj.user file checked-in (you shouldn't). Mar 29, 2016 at 16:58
  • 1
    So it is [a local setting]. I had previously assumed that all the project settings in that area were stored in team csproj. I had previously tried changing the URL that the browser would open by modifying "Project URL" and saw that it got changed in .csproj. Upon closer inspection, I now see that there is a "Apply server settings to all users" checkmark which controls just that field. My bad.
    – mejdev
    Mar 29, 2016 at 17:06
  • 2
    @PawelKrakowiak This doesn't seem to work. It opens the new tab regardless of checking the setting. Nov 7, 2016 at 15:12
  • 4
    For Visual Studio on Mac, the comparable settings is under "Project > Options > Run > Default > ASP.NET Core". Uncheck the "Open URL in web browser when app starts".
    – AdvApp
    Jun 6, 2017 at 18:17
245

For VS 15.7.1 ToolsOptionsProjects and SolutionsWeb Projects → uncheck Stop debugger when browser window is closed.

9
  • 6
    VS 15 is Visual Studio 2017, BTW.
    – Uwe Keim
    Dec 10, 2018 at 6:58
  • 6
    Suggested change don't do what the question is about. Sep 18, 2019 at 19:14
  • 3
    Works fine in VS2019 (16.4.4) Feb 5, 2020 at 10:10
  • For me, this is true answer. vs2019 16.8.3
    – Died
    Dec 22, 2020 at 12:16
  • 1
    Also works in VS2022 RC3 (ie Version 17.0.0 RC3)
    – SAL
    Nov 1, 2021 at 17:55
130

Updated answer for a .NET Core Web Api project...

Right-click on your project, select "Properties," go to "Debug" and untick the "Launch browser" checkbox (enabled by default).

enter image description here

3
  • 1
    @Grey Where is this option "Launch Browser"option present? May 14, 2019 at 10:41
  • I've updated the answer: You've to go to the properties of your project to get to the option.
    – CennoxX
    Jun 12, 2019 at 14:03
  • it has changed for VS 2022..
    – Irf
    Oct 4, 2022 at 9:20
70

In an ASP.Net 5 project this can now be set for each launch profile.

Open the file launchsettings.json under the Startup Project Properties folder and add "launchBrowser": false to the profile you are configuring, such as in:

"profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    }
}
1
  • Perfect answer which I was looking for Thanks Jul 3, 2022 at 9:17
34

In Visual Studio 2019, I resolved the same issue as below:

Go to your Visual Studio options Tools >>> Options >>> Project and Solutions >>> Web Projects then finally untick option >>> Stop debugger browser window is closed, close browser when debugging stops

Step 1:

enter image description here

Step 2: untick option >>> Stop debugger browser window is closed, close browser when debugging stops

enter image description here

Step 3:

Then finally click on >>> OK button, these are all the steps to resolve the issue.

2
  • 1
    This answer works even for visual studio 2019 Preview (Version 16.8.0 Preview 6.0)
    – Jake
    Oct 28, 2020 at 9:48
  • 4
    Magic, also works for VS 2022
    – Vnuuk
    Feb 2, 2022 at 21:48
26

I have solved my problem by following below steps. Go to Tools >> Click on options >> click on projects and solutions >> web projects >> uncheck "Stop debugging when browser is closed" optionenter image description here

2
  • underrated answer
    – Bimal Das
    Feb 14, 2020 at 10:30
  • I was looking for a way to stop visual studio from launching a new browser when starting debug, but open a new tab in current browser instead. It makes no sense why, but disabling this makes it work. Aug 17, 2021 at 10:45
20

This workaround works for me for VS 2019

Tools => Options

Then type Projects and solutions in the search box.

Select the Web Projects.

Then deselect the option below.

Stop debugger when browser window is closed, close browser when debugging stops.

This works for me. Hope this will help.

1
  • 2
    It still opens a new tab every time when I start debugging.
    – mimic
    Apr 3, 2020 at 2:27
16

As I did not had the mentioned option in my VS which is Visual Studio Enterprise 2017, I had to look for some other option.

Here is it what I've found:

Go to Tools -> Options -> Debugging tab(General) and uncheck "Enable JavaScript debugging for Asp.Net(Chrome and IE).

enter image description here

0
12

You can use the Attach To Process function, rather than pressing F5.

This can also allow you to navigate through known working sections without the slowdown of VS debugger loaded underneath.

4
  • I've tried that, but it won't stop execution when it finds a breakpoint. I need it to stop at breakpoints, is there a way to enable that? Thanks.
    – sker
    Apr 4, 2009 at 5:02
  • 1
    provided that your attached to a process which has loaded the exact same assemblies which are in the /bin/ folder of the application all breakpoints will work (oh, and provided there are .pdb files!) Apr 4, 2009 at 5:51
  • I Googled on how to fix that but it seems like a lot of trouble. I couldn't get it to work. I'll use I Have the Hat's solution in the meanwhile. Thank you.
    – sker
    Apr 4, 2009 at 9:01
  • I can debug by pressing F5 with the "wait for a request from an external application" option, but I can't get Attach To Process to work (attaching to INetMgr.exe). Never stops at a breakpoint. I was using VSCommands in VS 2013, but the new 2015 version of VSCommands doesn't support "Attach to IIS" yet. Wish I knew what the issue was.
    – ErikE
    Jan 23, 2016 at 0:09
9

When you first open a web/app project, do a Ctrl-F5, which is the shortcut for starting the application without debugging. Then when you subsequently hit F5 and launch the debugger, it will use that instance of IE. Then stop and start the debugging in Visual Studio instead of closing IE.

It works on my machines. I'm using the built in dev web server. Don't know if that makes a difference.

Firefox will also stay open so you can debug in either or both at the same time.

2
  • Hey that works! Thanks a lot. Now I can avoid around 100 extra windows per coding session. Also, when I hit F5 VS resizes my IE window. Do you know how can I avoid that?
    – sker
    Apr 4, 2009 at 5:35
  • Sorry sker, I don't know the answer to that--it doesn't happen for me doing the above though, so there probably is an answer somewhere. Maybe IE is remembering its window size and it's unrelated to the debugging scenario?
    – Rex Miller
    Apr 6, 2009 at 20:14
9

Here's what did it for me:

Go to Project Properties > Debug > Uncheck "Launch Browser" > Save.

enter image description here

8

There seems to be one case in which none of the above but the following helps. I'm developing a project for Windows Azure cloud platform and I have a web role. There is indeed a radio button Don't open page in Project -> {Project name} properties... as was pointed out by Pawel Krakowiak, but it has no effect in my case whatsoever. However, there is the main cloud project in solution explorer and there is the Roles folder under it. If I right click my web role in this folder and choose Properties, I get another set of settings and on the Configuration tab there is the Launch browser for flag, after unchecking it a new browser window is not opened on application start up.

6

Joao Costa answer also holds true for .Net core 2 projects.

launchsettings.json --> "launchBrowser": false

"profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "environmentVariables": {
        "Hosting:Environment": "Development"
      }
    }
}
1
  • 3
    This was super helpful. Worth noting that this launchSettings.json is hidden under Properties "Folder" in "Solution Explorer"
    – netpoetica
    May 6, 2020 at 1:23
4

While there are several excellent answers, ranging from usual suspects to newer solutions, I would like to provide one more to the fray that addresses what you should do when you are working on a solution with multiple projects.

Before I arrived at this solution, I kept looking at bindingInformation in the applicationhost.config of the solution, tirelessly looking for any hint of why things were simply not working.

Turns out, the simple thing that I overlooked was that different projects have individual settings too.

So, besides Project > {Project-Name} Properties... > Web > Start Action on my Backend Project, I also had to Go to Website > Start Options... > Start Action on my Frontend Project. Once there, I selected Don't open a page. Wait for a request from an external application and have been happy ever since!

Backend Settings Frontend Settings

4

Looks like it has changed for VS 2022,

Now it has a dedicated UI,

Right Click the project (in Solution explorer) > select Properties then follow :-

enter image description here


enter image description here "uncheck" the option for it to not open automatically.

OR you can click the menu bar, Debug > Properties

enter image description here

and you can reach the Step-2 "launch profiles" directly from there

or a shortcut:

Select the project ( in Solution explorer) and press Alt + Enter and then follow from there..

3

I looked over the answers and didn't see the solution I found mentioned. If it was, my apologies. In my case, currently using Visual Studio 2015. In the solution explorer, right click on the Project file and click properties. Go to the Debug tab and this should have info for how you're launching "IIS Express or Web(DNX)" for the first two drop downs, and then there should be a checkmark box for "Launch URL:". Uncheck this option and your browser won't be automatically launched everytime you go to debug your application. Hope this helps someone out.

3

You can right click on your project, then choose Properties , on Debug tab you should uncheck launch browser checkbox.

1

CTRL+ALT+ENTER if your amends are front end only

http://blogs.msdn.com/b/webdev/archive/2013/06/28/browser-link-feature-in-visual-studio-preview-2013.aspx

1

You can now also get to the Web properties by clicking the dropdown arrow next to the Run button!

  1. Click dropdown button next to "Run"
  2. { Project name } Properties
  3. Click "Web" in the list on the left
  4. Under the "Start Action" segment, click Don't open a page.

You're all set!

PS: This works for me, I'm on version 16.5.5 of VS Professional 2019 :)

1

If you're using the Web Publish feature in IIS, then the solution I found was to edit the publish configuration and remove the Destination URL from the configuration (leave it blank).

If this is defined, then every time you publish the project it will open the URL specified in the Destination URL (which is a redirect URL).

Reference: https://support.winhost.com/kb/a1604/visual-studio-publish-web-deploy.aspx

0

For VS2022 and ASP.NET Core:

Another shortcut is: to click the small dropdown button on the right side green-triangle button with the project's name on it, which usually launches the debug build. and then the last option "{project name} Debug Properties" which launches the dedicated UI window directly.

enter image description here

From there follow @irf's advice:

"uncheck" the option for it to not open automatically.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.