.net core ubuntu 使用服务时更改端口

Jer*_*Loh 5 service kestrel asp.net-core ubuntu-16.04

我正在尝试在使用该服务时测试在不同端口上运行 .net core。

但是,我不断收到状态代码 140 的错误。

这发生在我的两次尝试中:

1)在服务文件中 添加 --server.urls= http://0.0.0.0:555 2)在 Program.cs 中ExecStart=/usr/bin/dotnet /dotnetcore/published/TestingWebApi.dll 添加 UseUrls(" http://0.0.0.0:555 ")

当我使用它的代码手动运行它时 dotnet run --server.urls=http:0.0.0.0:555

有人设法使用该服务获得它吗?

小智 2

使用以下内容

ExecStart=/usr/bin/dotnet /dotnetcore/published/TestingWebApi.dll --urls http://localhost:5002
Run Code Online (Sandbox Code Playgroud)