Asp.Net Core Web API app: how to change listening address?

后端 未结 3 579
名媛妹妹
名媛妹妹 2020-12-15 11:16

I write simple Asp.Net Core WebAPI 2.0 application, it works on my local machine. But i want to deploy it to server. So, i do it.

My system:

Ubuntu 1         


        
3条回答
  •  难免孤独
    2020-12-15 11:54

    I'm using .NETCore 2.1 prev, so I haven't been able to test it myself but if I believe that https://www.billbogaiv.com/posts/setting-aspnet-host-address-in-net-core-2, adding .UseUrls(urls: "http://*:5000") might be instructing Kestrel to listen to port 5000 and not only on localhost, so it should work also on a remote server.

    Other possible solution, UseKestrel(..) https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.1&tabs=aspnetcore2x using IPAddress.Any instead of Loopback.

提交回复
热议问题