Blazor WASM Net 6 Preview 4 Azure AD - 尝试登录时出错:“无法读取未定义的 属性 'toLowerCase'”
Blazor WASM Net 6 Preview 4 Azure AD - There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'
我有一个简单的 Blazor WASM 运行 Net 6 Preview 4,我使用本指南进行设置:
确切的代码与 Net 5.0 完美配合(使用相应的 Net 5.0 程序集)
然而,当我升级到 Net 6 时,我收到以下身份验证错误:
There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'
我似乎也无法获得更多细节。这是在 Azure App Service Self Contained publish 上发布的。
代码可以在这里找到:
https://github.com/aherrick/BlazorWASM.Net6Prev4.AzureAD
此处讨论了该问题的解决方法:
https://github.com/dotnet/aspnetcore/issues/33312.
简而言之,问题是由程序集修整引起的。解决方法是通过在客户端项目文件中包含以下内容来排除 Microsoft.Authentication.WebAssembly.Msal
修剪:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>
我在尝试登录时遇到了同样的问题。正在将 Microsoft.Identity.Web 和 Microsoft.Identity.Web.UI 更新到最新版本 (1.22.1),然后删除 bin 和 obj 文件夹解决了我的问题。
无需使用 TrimmerRootAssembly 添加 ItemGroup。
我有一个简单的 Blazor WASM 运行 Net 6 Preview 4,我使用本指南进行设置:
确切的代码与 Net 5.0 完美配合(使用相应的 Net 5.0 程序集)
然而,当我升级到 Net 6 时,我收到以下身份验证错误:
There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'
我似乎也无法获得更多细节。这是在 Azure App Service Self Contained publish 上发布的。
代码可以在这里找到: https://github.com/aherrick/BlazorWASM.Net6Prev4.AzureAD
此处讨论了该问题的解决方法: https://github.com/dotnet/aspnetcore/issues/33312.
简而言之,问题是由程序集修整引起的。解决方法是通过在客户端项目文件中包含以下内容来排除 Microsoft.Authentication.WebAssembly.Msal
修剪:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>
我在尝试登录时遇到了同样的问题。正在将 Microsoft.Identity.Web 和 Microsoft.Identity.Web.UI 更新到最新版本 (1.22.1),然后删除 bin 和 obj 文件夹解决了我的问题。
无需使用 TrimmerRootAssembly 添加 ItemGroup。