[英]VSCode debug ASP.NET Core app launch browser on specific port
I have the following .vscode/launch.json: 我有以下.vscode / launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "My Web App",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-frontend",
"program": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2/MyWebAp.dll",
"args": [],
"cwd": "${workspaceFolder}/src/MyWebApp/bin/Debug/netcoreapp2.2",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5001"
},
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}",
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/src/MyWebAppb/Views"
},
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
However, debug session always opens up the browser at default port 5000. It doesn't honour the ASPNETCORE_URLS
. 但是,调试会话始终在默认端口5000处打开浏览器。它不支持
ASPNETCORE_URLS
。 Any advice and insight is appreciated. 任何建议和见解表示赞赏。
I think you must set the launchSettings.json file port like this too 我认为你也必须像这样设置launchSettings.json文件端口
"WebApp1": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001/"
}
问题的根本原因是我在5000上的program.cs中配置了kestrel。将其更改为所需的端口号并且它可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.