This is going to be a very short post. I am adding it because I have run across it several times and every time I need to Google it (or ask a co-worker) how to fix it.
Why is my browser launching a new window?
When you run your web application one of two things may happen:
Your application may open in:
- A new browser tab opens in current web browser
- New web browser opens.
The issue with this is that when it opens in the current web browser if you close the tab the application will continue to run. However if you close it when it has opened in a new web browser window then your application will stop.
Open in current browser
If you want want it to open in a new tab in your current browser then you will need to disable JavaScript debugging for ASP.Net. Go to Tools -> Options -> Debugging -> General Make sure the option is unchecked.
How to not launch a browser.
Go to the launchSettings.json file in your Visual studio project, look for the following line.
“launchBrowser”: true,
change it to
“launchBrowser”: false,
This will stop it from launching a browser at all.
Conclusion
JavaScript debugging for ASP.Net defines if the browser will open in a new tab or a whole new browser window. The launchSettings.json file gives you the ability to set how you want your web application to start up. You can start it up in a browser or not. Depending upon where the browser window was open may effect whether or not you application will continue to run when the browser is closed.