【发布时间】:2021-11-21 04:10:35
【问题描述】:
我在 https://localhost:5001/ 上运行客户端 blazor wasm,在 https://localhost:44302/ 上运行由 http.sys 托管的 API 服务器。 我已经为 http.sys 设置了 Windows 身份验证,如此处https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-5.0&tabs=visual-studio#httpsys
中所述现在,当在 Blazor wasm 上使用 HttpClient 并通过 [Authorize] 到达控制器或集线器时,我立即获得未授权。
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Response status code does not indicate success: 401 (Unauthorized).
System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized) with exception
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync(Uri url, HttpClient httpClient, ILogger logger, CancellationToken cancellationToken)
我想知道为什么没有弹出对话框来设置凭据。
相比之下,当我使用 IIS 托管 Blazor wasm 时,它会显示浏览器弹出登录。
非常感谢您的回答。
【问题讨论】:
-
您是说发布到 iis 时一切正常,但在 Visual Studio f5 中测试时出现问题?
-
当我在 VisualStudio 中使用 IIS 时它运行良好,当我切换到 API 到 http.sys 和 blazor wasm 独立时它停止了,但我想通了。
标签: asp.net-core signalr blazor blazor-webassembly httpsys