运行应用程序时,在VSCode中的ASP.NET Core应用程序中启动特定的URL

时间:2019-11-25 02:13:42

标签: c# asp.net-core visual-studio-code vscode-settings

(如果重要,请在Mac上运行。)

在Visual Studio中,您可以在运行或调试ASP.NET Core项目时使用此方法启动特定的URL。使用launchUrl属性。这是一个示例launchSettings.json文件:

{
  "profiles": {
    "MyProjectName": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "customstartupurlgoeshere/?id=theanswertotheuniverse",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:5001;http://localhost:5000"
    }
  }
}

VS Code中的模拟是什么?我读到VS Code忽略了launchSettings.json文件。

1 个答案:

答案 0 :(得分:0)

VSCode在启动程序时采用.vscode/launch.json配置。

  

使用了launchUrl属性.... VS Code中的模拟是什么?

您可以更改args参数以接受--urls的参数。例如,如果您想让茶est听6001 / 6000

"configurations": [
    {
        "name": ".NET Core Launch (web)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/App.dll",
        "args": ["--urls","https://localhost:6001;http://localhost:6000"],
        "cwd": "${workspaceFolder}",
        "stopAtEntry": false,
        "serverReadyAction": {
            "action": "openExternally",
            "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
        },
        "env": {
            "ASPNETCORE_ENVIRONMENT": "Development"
        },
        "sourceFileMap": {
            "/Views": "${workspaceFolder}/Views"
        }
    },