【问题标题】:how to run web application from visual studio code如何从 Visual Studio 代码运行 Web 应用程序
【发布时间】:2018-02-14 09:40:26
【问题描述】:

我在 Visual Studio 代码中创建了一个空的 Web 应用程序。但是当使用“dotnet run”运行它时,它没有打开任何浏览器 它只显示以下几行。

>C:\Users\viru babu\Documents\MVCcoreLinkdin>dotnet run
   >Hosting environment: Production
   >Content root path: C:\Users\viru babu\Documents\MVCcoreLinkdin
   >Now listening on: http://localhost:5000
   >Application started. Press Ctrl+C to shut down.

【问题讨论】:

  • 您是否尝试在浏览器中打开地址localhost:5000
  • @ztadic91 ,现在我尝试了它的工作,但为什么它没有自动打开。

标签: asp.net asp.net-core visual-studio-code


【解决方案1】:

要在http://localhost:5000 上自动打开浏览器,您可以添加配置到您的launch.json。添加这样的配置:

{
    "name": "Chrome",
    "type": "chrome",
    "runtimeExecutable": "./path/to/chrome.exe",
    "request": "launch",
    "url": "http://localhost:5000",
    "webRoot": "${workspaceRoot}",          // maybe you need to adjust this entry to "C:\Users\viru babu\Documents\MVCcoreLinkdin"
    "preLaunchTask": "shell: dotnet run"           // add prelaunch task  start (defined in tasks.json)
}

要自动启动您的应用程序,您可以使用preLaunchTask。为此,您需要在运行您的命令dotnet runtasks.json 中配置custom task

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-30
    • 2019-03-18
    • 1970-01-01
    相关资源
    最近更新 更多