如何从visual studio代码运行Web应用程序

时间:2018-02-14 09:40:26

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

  

我在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.

enter image description here

1 个答案:

答案 0 :(得分:0)

要在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。为此,您需要在运行命令tasks.json的{​​{1}}中配置custom task