运行应用程序时,在VSCode中的ASP.NET Core应用程序中启动特定的URL [英] Launch specific URL in an ASP.NET Core app in VSCode when running the app

查看:140
本文介绍了运行应用程序时,在VSCode中的ASP.NET Core应用程序中启动特定的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

(Running on a Mac if that matters.)

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

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"
    }
  }
}

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

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

推荐答案

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

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

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

您可以更改 args 参数以接受-urls 的参数.例如,如果要使红the监听 6001 / 6000 :

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"
        }
    },

这篇关于运行应用程序时,在VSCode中的ASP.NET Core应用程序中启动特定的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆