更新: 刚刚尝试了官方示例https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/fundamentals/servers/httpsys/samples/3.x/SampleApp并且它不起作用。
浏览器消息:
This site can’t provide a secure connection
localhost sent an invalid response.
输出:
信息:Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] 用户配置文件可用。使用“C:\Users\xxx\AppData\Local\ASP.NET\DataProtection-Keys”作为密钥存储库和 Windows DPAPI 来加密静态密钥。 警告:Microsoft.AspNetCore.Server.HttpSys.MessagePump[0] 覆盖地址“https://localhost:5001, http://localhost:5000”。绑定到添加到 UrlPrefixes 的端点。 信息:Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] 开始 信息:Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] 监听前缀:http://localhost:5005/ 信息:Microsoft.Hosting.Lifetime[0] 现在收听:http://localhost:5005/ 信息:Microsoft.Hosting.Lifetime[0] 申请开始。按 Ctrl+C 关闭。 信息:Microsoft.Hosting.Lifetime[0] 托管环境:开发 信息:Microsoft.Hosting.Lifetime[0] 内容根路径:C:\Users\xxx\Downloads\AspNetCore.Docs-master\AspNetCore.Docs-master\aspnetcore\fundamentals\servers\httpsys\samples\3.x\SampleApp
我使用 Windows 身份验证创建了一个新的 Blazor 应用程序。(Visual Studio 2019 V16.4.0,.Net Core 3.1)。
现在,在 Visual Studio 中使用 IIS Express 运行时,Windows 身份验证有效(网页右上角显示“Hello Domain\Username!”)。但是当作为 Kestrel 应用程序运行时,Windows 身份验证不起作用。
我按照以下链接中的步骤使 Windows 身份验证与 Http.Sys 一起工作。(顺便说一句,我试过 [Kestrel/Negotiate][1] 但没有运气)
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/httpsys?view=aspnetcore-3.1
基本上,它只是添加了webBuilder.UseHttpSys()
in CreateHostBuilder()
in的调用Program.cs
。
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseHttpSys(options =>
{
options.AllowSynchronousIO = true;
options.Authentication.Schemes = AuthenticationSchemes.None;
options.Authentication.AllowAnonymous = true;
options.MaxConnections = null;
options.MaxRequestBodySize = 30000000;
// options.UrlPrefixes.Add("http://*:5005");
});
webBuilder.UseStartup<Startup>();
});
但是,运行应用程序会得到一个错误页面,其中包含以下消息
This site can’t be reached
The connection was reset.
或者
This site can’t provide a secure connection
localhost sent an invalid response.
Edge 的错误消息是:
There was a temporary DNS error. Try refreshing the page.
Error Code: INET_E_RESOURCE_NOT_FOUND
IE 错误信息:
无法安全连接到此页面
这可能是因为该站点使用过时或不安全的 TLS 安全设置。如果这种情况持续发生,请尝试联系网站所有者。