mejobloggs
mejobloggs

Reputation: 8156

How to stop browser closing automatically when you stop debugging on VS 2017

I'm trying out the new VS 2017 RC and wondering if anyone knows how to get the previous debugging behavior back

In VS 2015 it went like this:

Press start debugging

Now in 2017:

Is it possible in 2017 to switch back to the 2015 style? So the Chrome/Website window can dock with other Chrome windows/tabs, and it stays open after you stop debugging?

Additionally, I find the new Chrome window frustrating to use, as it seems not to have any history/content available. E.g I can't autocomplete forms or urls, which is very annoying when I'm trying to test a form

Upvotes: 454

Views: 170640

Answers (7)

jerone
jerone

Reputation: 16861

Visual Studio 2017 version 15.7 and higher & Visual Studio 2019 changed things again.

Disabling the following checkboxes will allow you to keep the browser open (doesn't close after stop debugging) and opens another tab (instead of another window):

enter image description here

enter image description here

Tools > Options > Debugging > General

  • Disable "Enable JavaScript debugging for ASP.NET (Chrome, Edge and IE)".

Tools > Options > Projects and Solutions > Web Projects

  • (Visual Studio 2017) Disable "Stop debugger when browser window is closed".
  • (Visual Studio 2019 and higher) Disable "Stop debugger when browser window is closed, close browser when debugging stops".

Upvotes: 802

willingdev
willingdev

Reputation: 9546

If your project is .net core: in Properties folder > launchSettings.json file set this config :

"launchBrowser": false,

Else in visual studio 2022 : Tools > Options > Projects and Solutions > Web Projects

uncheck : Stop debugger when browser window is closed, close browser when debugging stops

enter image description here

Upvotes: 27

For those of you who updated to Visual Studio 2019, that config is now under Tools > Options...

And then in the options dialog (see image below) Projects and Solutions > Web Project :
Uncheck Stop debugger when broswer window is closed, close browser when debugging

enter image description here

Upvotes: 63

Can PERK
Can PERK

Reputation: 630

Go to Tools -> Options and search for "Stop Debugger". Then select the node Web Projects under Projects and Solutions. Uncheck "Stop debugger when browser window is closed". Before this option your should apply @jerone's suggestion.

PS: This option can be used after VS version 15.7

Upvotes: 12

Pieczarr
Pieczarr

Reputation: 358

I am writing this answer as I think the previous ones cover only half of the problem.

First thing you want is to get rid of this annoying 'run chrome as a new window and auto-close when stopped debugging'

Tools → Options → uncheck Enable JavaScript debugging for ASP.NET

After doing that when starting debugging chrome opens a new tab, after stopping the tab is not closed but refreshing website shows white screen

again in the Tools → Options

uncheck Enable Edit and Continue

Since now you have your old behaviour back.

Options window

Upvotes: 29

Mads Kvist Kristensen
Mads Kvist Kristensen

Reputation: 2620

The reason for the change in behavior is due to VS 2017's support for debugging JavaScript/TypeScript running in Chrome. See announcement here https://blogs.msdn.microsoft.com/webdev/2016/11/21/client-side-debugging-of-asp-net-projects-in-google-chrome/

To return to the 2015 behavior where Chrome is not closed by the debugger, disable the IE/Chrome script debugger in Tools -> Options like so:

Debugger options

Upvotes: 90

Michael Braude
Michael Braude

Reputation: 6973

There are two ways to do this:

  1. Either Launch without debugging by pressing ctrl + f5 or
  2. Launch with debugging (pressing f5) and then go to the Debug menu and press "Detach All"

Hope that helps.

Upvotes: 2

Related Questions