177

when I try to run a web application in visual studio 2017RC on windows 10, it opens a new browser instance(in my case chrome). I've tried also with internet explorer, situation is same, and browser not signed in, but if I just manually run chrome it is signed in. How to prevent visual studio to run a new browser instance on each time I run web application? When I press run website it should be opened in same window as previous application(just next tab)

10
  • you want it to open new tab?
    – Alexan
    Feb 7, 2017 at 17:03
  • @Alex, how to prevent opening new instance, not a tab, another process...
    – ovasylenko
    Feb 7, 2017 at 18:15
  • In which menu I can find this? api.monosnap.com/rpc/file/… . This is it?
    – ovasylenko
    Feb 10, 2017 at 7:34
  • yes, I just thought that maybe your default is incognito browser
    – Alexan
    Feb 10, 2017 at 14:31
  • @Alex, no my browser is not in incognito by default
    – ovasylenko
    Feb 13, 2017 at 7:56

8 Answers 8

363

I've discovered that Turning off Javascript debugging means that sites open in a new tab of an existing Chrome instance. From what I've seen the in Visual Studio debugging is not as good as Chrome's dev tools so turning this off is not an issue for me.

Turn off javascript debugging

UPDATE

As of VS2017 15.7.1 (and still the case in VS2019 16.0.0 and VS2022 17.0.0 PREVIEW) this fix no longer works and I've found I've had to additionally uncheck Stop debugger when browser window is closed

enter image description here

9
  • It was as simple as noticing that there was a specific debugging option for Chrome and experimenting.
    – Fishcake
    Jan 11, 2018 at 13:42
  • 1
    I've just updated to 15.7.1 am now getting a new window open.
    – Fishcake
    May 9, 2018 at 9:26
  • 8
    @niico Updated answer restores the functionality of opening in an existing browser (for me at least).
    – Fishcake
    May 9, 2018 at 9:42
  • 1
    @HaveSpacesuit I believe it's not a bug, but rather intentional. In order to stop debugger when browser window is closed, I guess they had to open a brand new browser window (I'm not sure, though). That's why disabling this new feature makes the project to open in a new tab on existing browser. May 11, 2018 at 11:55
  • 3
    Thanks for the 15.7.1 update. This is a VS bug imo. VS should have the "stop debugger when browser window is closed" unchecked by default so that it acts the same as previous versions
    – Matt Frear
    May 23, 2018 at 9:00
50

There is solution to that problem. Very Simple please follows the below Steps.

  • Open Visual Studio
  • Go to "Tools" and then go to "Options"
  • Select "Projects and Solutions" and in that select "Web Projects"
  • Please uncheck this Option "Stop debugger when browser window is closed, close browser when debugging stops"
  • Click Ok

Now start project, it will not open in new chrome Instant but in a already running Chrome Instant.

1
  • 2
    Works for VS 2022 in 2022 Feb 1, 2022 at 9:33
17

You can disable the website from being launched at all from the debug settings.

ProjectSettings-Debug

Once the web application is running you can launch the website from the taskbar.

enter image description here

The "Browse With..." menu option appears to launch the website without running the debug session in VS2017 which might not be what you want.

2
  • I don't want to disable launching. I just want to prevent opening new browser windows each time I run my application. When I press run website it should be opened in same window as previous application (just next tab)
    – ovasylenko
    Feb 10, 2017 at 7:37
  • 7
    I know this answer didn't answer the OPs question, but it helped me :-)
    – Lee Oades
    May 30, 2017 at 13:53
12

I wanted to share the reason of the issue as well as the screen shot. The reason for which it opens a new window is because JS debugging is enabled. Chrome is launched with debugging enabled so a new instance is required. If you want to revert to the old behavior from Visual Studio 2015, you can do so but you would have to disable JS debugging. See below:

enter image description here

Original Source

Original Discussion on Visual Studio Forum

10

In VS 2022 the option: Stop debugger when browser window is closed,
was moved to: Tools>>Options>>Projects and Solutions>>Web Projects

enter image description here

2
  • I think you may mean Tools > Options > Projects and Solutions > Web Projects.
    – Simon Elms
    Dec 6, 2022 at 4:57
  • 1
    My bad - I forgot "Projects and Solutions" and edited my answer -TNX Dec 6, 2022 at 5:01
8

This workaround works for me for VS 2019

Tools => Options

Then type Projects and Solutions in the search box.

Then Select Web Project.

Then deselect the below option.

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

This works for me. Hope this will help.

1
  • 2
    Same thing for VS 2022
    – Ogglas
    Nov 18, 2021 at 13:37
7

I prefer to set mine like this, I run the page from where I want (no new instance or tab opening)

Project Properties Window

2

Have a look into this link. you will find solution for your question and some more information about what happens when you start/stop debugging and when you close the browser window

1
  • After the post you refer to was written, this is the correct answer.
    – doterik
    Oct 6, 2020 at 9:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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