VSCode launch ASP.NET Core app on a specific port

2020-05-31 12:18发布

From launch.json, what is the correct way to launch an ASP.NET Core on a specific port? For instance, when I run my .NET Core app, VS Code, hosts it on localhost:5000, but I instead want to host it on localhost:5050.

Thanks in advance.

1条回答
Evening l夕情丶
2楼-- · 2020-05-31 12:48

You can config it via environment variable ASPNETCORE_URLS

macOS:

export ASPNETCORE_URLS=http://localhost:5050

windows:

set ASPNETCORE_URLS=http://localhost:5050

or add this to launch.json

  "env": {
    "ASPNETCORE_URLS": "http://localhost:5050"
  }

If you don't want to specify the hostname, you can use * instead

http://*:5050
查看更多
登录 后发表回答