【发布时间】:2019-04-08 13:02:31
【问题描述】:
环境:Ubuntu 18.04下的ASP.NET Core 2.1
默认情况下,新创建的 asp.net 核心应用在http://localhost:5000 运行并自动重定向到https://localhost:5001
由于我打算在 nginx 下运行我的应用程序(并使用 nginx 的 SSL 功能),我想在没有 https 的情况下在特定端口(例如 6000)上运行我发布的应用程序。
帖子ASP.NET Core 2.1 + Kestrel (How to disable HTTPS) 解释说,必须简单地使用“--urls”参数来实现这一点。
这是我尝试过的:
$ dotnet publish --configuration Release
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
该应用现在开始在http://localhost:5000 和https://localhost:5001 上收听。当我浏览到http://localhost:5000 时,它会自动重定向到https://localhost:5001。到目前为止一切顺利。
现在,我尝试在 6000 端口运行:
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
--urls="http://localhost:6000"
从终端窗口中的消息来看,该应用似乎开始在http://localhost:6000 监听。但是,浏览到此 url 会导致“无法访问此站点”错误。
我什至尝试过:
$ dotnet bin/Release/netcoreapp2.1/MyApp.dll
--urls="http://localhost:6000,https://localhost:6001"
在这种情况下,我收到“路径基只能使用 IApplicationBuilder.UsePathBase() 配置”的错误。
谁能告诉我如何在指定端口简单地运行应用程序?我希望我不需要硬编码端口号。
【问题讨论】:
标签: asp.net-core