Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
936 views
in Technique[技术] by (71.8m points)

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

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 16.04.
Asp.Net WebAPI 2.0 (and dotnet version 2.1.105)

But, when app starts it writes:

Now listening on:http://localhost:53115

When i try to get values from it:

  http://id_address:53115/api/values

And i can not get response. In Postman:

 Could not get any response
 There was an error connecting to 
 http://id_address:53115/api/values.
 Why this might have happened:
 The server couldn't send a response:
 Ensure that the backend is working properly
 Self-signed SSL certificates are being blocked:
 Fix this by turning off 'SSL certificate verification' in Settings > General
 Proxy configured incorrectly
 Ensure that proxy is configured correctly in Settings > Proxy
 Request timeout:
 Change request timeout in Settings > General

What i should do? Can you tell me how to fix that?

I do not know where to start looking for.

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...