我正在测试官方的Asp.Net核心示例https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/servers/httpsys/samples/3.x/SampleApp,正在使用Visual Studio 2019 V16.4.0(.Net 3.1)
我注释了// options.UrlPrefixes.Add("http://localhost:5005");
行,因此它将对https和http分别使用默认端口5001和5000。
Visual Studio显示它正在https://localhost:5001上监听。
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using 'C:\Users\xxx\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] Start info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] Listening on prefix: https://localhost:5001/ info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] Listening on prefix: http://localhost:5000/ info: Microsoft.Hosting.Lifetime[0] Now listening on: https://localhost:5001 info: Microsoft.Hosting.Lifetime[0] Now listening on: http://localhost:5000 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp
但是,在运行exe文件时,它不会监听https://localhost:5001
PS C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp\bin\Debug\netcoreapp3.1> .\HttpSysSample.exe info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using 'C:\Users\xxx\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] Start info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] Listening on prefix: http://localhost:5000/ info: Microsoft.Hosting.Lifetime[0] Now listening on: http://localhost:5000 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp\bin\Debug\netcoreapp3.1
网页在Chrome中返回以下消息。
无法访问此网站
连接已重置。
在Edge中,它显示
无法安全连接到此页面
这可能是因为该站点使用了过时或不安全的TLS安全设置。如果这种情况持续发生,请尝试与网站所有者联系。
更新:
运行.\HttpSysSample.exe --urls https://*:5005
可以通过命令行执行启用https。但是,上面会得到相同的错误。