Asp.Net Core Web API应用程序:如何更改监听地址?

编程入门 行业动态 更新时间:2024-10-23 06:29:30
本文介绍了Asp.Net Core Web API应用程序:如何更改监听地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我编写了一个简单的Asp.Net Core WebAPI 2.0应用程序,它可以在我的本地计算机上运行. 但我想将其部署到服务器. 所以,我做到了.

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.

我的系统:

Ubuntu 16.04. Asp.Net WebAPI 2.0 (and dotnet version 2.1.105)

但是,当应用启动时,它会写:

But, when app starts it writes:

Now listening on:localhost:53115

当我尝试从中获取价值时:

When i try to get values from it:

id_address:53115/api/values

我无法得到回应. 在邮递员中:

And i can not get response. In Postman:

Could not get any response There was an error connecting to 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.

谢谢!

推荐答案

我正在使用.NETCore 2.1 prev,所以我自己无法对其进行测试,但是如果我相信 www.billbogaiv/posts/setting-aspnet-host-address -in-net-core-2 ,添加.UseUrls(urls: "*:5000")可能指示Kestrel监听端口5000,不仅在本地主机上,因此它也应在远程服务器上工作.

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

其他可能的解决方案,UseKestrel(..) docs.microsoft/zh-cn/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.1&tabs=aspnetcore2x 使用IPAddress.Any而不是Loopback.

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

更多推荐

Asp.Net Core Web API应用程序:如何更改监听地址?

本文发布于:2023-11-15 10:26:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1593602.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   如何更改   地址   Net   Asp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!