ubuntu - Asp.Net Core Web API 应用程序:如何更改监听地址?
问题描述
我编写了简单的 Asp.Net Core WebAPI 2.0 应用程序,它可以在我的本地机器上运行。但我想将它部署到服务器。所以,我做到了。
我的系统:
Ubuntu 16.04.
Asp.Net WebAPI 2.0 (and dotnet version 2.1.105)
但是,当应用程序启动时,它会写道:
Now listening on:http://localhost:53115
当我尝试从中获取值时:
http://id_address:53115/api/values
我无法得到回应。在邮递员中:
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
我该做什么?你能告诉我如何解决这个问题吗?
我不知道从哪里开始寻找。
谢谢!
解决方案
我正在使用 .NETCore 2.1 prev,所以我自己无法测试它,但如果我相信https://www.billbogaiv.com/posts/setting-aspnet-host-address-in-net-core -2,添加.UseUrls(urls: "http://*:5000")
可能会指示 Kestrel 侦听端口 5000 而不仅仅是在本地主机上,因此它也应该在远程服务器上工作。
其他可能的解决方案,UseKestrel(..)
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore -2.1&tabs=aspnetcore2x使用IPAddress.Any
而不是Loopback
.
推荐阅读
- asp.net - .Net 框架 Owin 测试服务器不适用于 WebSocket
- sql-server - 选择列表中的“Payment.Amount”列无效
- java - 打印阶乘递归方法时Java中的错误?在“打印命令”之前打印的输出
- c++ - 如何更改 swapchian 中的 D3D12_RESOURCE_FLAGS?
- python-3.x - 我们可以为未训练的类提取 VGG16/19 特征吗
- c - 如何在 C 中添加发布请求后给出的 cookie?
- visual-studio - Visual Studio 安装程序项目打包 DotNetCore 而不是 Framework
- sqlite - Flutter添加多个Sqlite表,+表日历
- shiny - r shiny:rhandsontable 列根据其他用户更新的列自动更新
- php - 尝试在控制器中使用两个参数传递命名路由时出现 500 内部错误