自从我将在 azure 上作为静态站点托管的 blazor wasm 项目更新到 .Net 7 以来,即使身份验证正常工作,用户也会被重定向到“______.com/authentication/login-failed”。然后他们可以毫无问题地浏览网站,但不会看到此错误。
我无法在本地重现此问题(仅发生在 azure 生产环境中),我收到的唯一错误是 404 not find。
“加载资源失败:服务器响应404状态(请求的内容不存在。)”
还有其他人经历过这种情况,并希望找到解决方案吗?
我可以回滚到 .Net 6,但这存在大量其他与身份验证相关的问题,.Net7 已修复这些问题。
最佳答案
将以下内容添加到 client.csproj 应该可以修复它:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
<TrimmerRootAssembly Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" />
</ItemGroup>
关于c# - 如何修复 Blazor WASM .NET 7 升级中的身份验证错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74721884/