'Launch specific URL in an ASP.NET Core app in VSCode when running the app

(Running on a Mac if that matters.)

In Visual Studio you use this method to launch a specific URL when running or debugging your ASP.NET Core project. The launchUrl property is used. This is a sample launchSettings.json file:

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

What's the analog in VS Code? I read that VS Code ignores the launchSettings.json file.



Solution 1:[1]

VSCode takes the .vscode/launch.json configuration when launching a program.

The launchUrl property is used .... What's the analog in VS Code?

You can change the args parameter to accept an argument of --urls. For example, if you want to make the kestrel listen on 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"
        }
    },

Solution 2:[2]

add this and set correct path to the file.

"launchSettingsFilePath": "${workspaceFolder}/Properties/launchSettings.json",

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 itminus
Solution 2 Kentonbmax