e.g
Every time i key ctrl + f5
or ctrl + shift + f5
to rerun asp.net core api project in vscode,it'll open a new tab.
I expect just restart program without opening new tab
.
How to not launch a browser. Go to the launchSettings.json file in your Visual studio project, look for the following line. This will stop it from launching a browser at all. JavaScript debugging for ASP.Net defines if the browser will open in a new tab or a whole new browser window.
The easiest way to get the Open in Browser option for Visual Studio Code in Windows is to use an extension. Installing extensions in Visual Studio Code is relatively straightforward, as is using them to open files in the browser. Open your HTML file in the Visual Studio Code Editor. On the far left vertical toolbar, click on “Extensions.”
By default when debugging an ASP.NET Core, VS Code will launch default browser. There is way to choose the browser you would like to use. Here is the code snippet which will add different debug configuration to VS Code. To use this, first you need to open launch.json file. You can find the launch.json file under .vscode folder.
Go to the launchSettings.json file in your Visual studio project, look for the following line. This will stop it from launching a browser at all. JavaScript debugging for ASP.Net defines if the browser will open in a new tab or a whole new browser window.
It can use dotnet watch
to do it .
If you don't want any browser tab be created,you colud go to .vscode\launch.json
remove serverReadyAction
and it can deal the problem.
default json :
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
}
]
}
just delete or mark serverReadyAction
then system'll not open any web browerser tab 🤗
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
//}
}
]
}
P.S
I test set launchBrowser enabled false
but it not work,it'll still create new tab.
launchBrowser enabled false launch.json :
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"launchBrowser": {
"enabled": false
},
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/ServerApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
Every kind of application shows you some kind of UI, prompt, or form. Otherwise, how would user know that’s its up and running.
By default, it’s open a new tab only.
Your project template itself is web API? then how can you expect the web without the browser?
Update: I tried setting the launchBrowser
to false
in launchSettings.json in Visual studio 2019, it’s launching like the below images.
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"launchUrl": "default",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
You are setting launchBrowser
to false
in wrong way, you have to do like this "launchBrowser": false
. Its working fine in Asp.Net Core 3.1 API.
You can see in the taskbar
If you don't want any browser tab be created,you colud go to .vscode\launch.json
remove serverReadyAction
and it can deal the problem.
default json :
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
}
}
]
}
just delete or mark serverReadyAction
then system'll not open any web browerser tab 🤗
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
//}
}
]
}
P.S
I test set launchBrowser enabled false
but it not work,it'll still create new tab.
launchBrowser enabled false launch.json :
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"launchBrowser": {
"enabled": false
},
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/ServerApp.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
//Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With