I have a simple Blazor WASM running Net 6 Preview 4 that I setup using this guide:
https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory?view=aspnetcore-6.0
The exact code works perfect with Net 5.0 (using corresponding Net 5.0 assemblies)
However when I upgrade to Net 6 I receive the following Authentication error:
There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'
I can't seem to get anymore detail either. This is published on Azure App Service Self Contained publish.
The code can be found here: https://github.com/aherrick/BlazorWASM.Net6Prev4.AzureAD
A workaround to the issue has been discussed here: https://github.com/dotnet/aspnetcore/issues/33312.
In short the issue is caused by assembly trimming. And the workaround is to exclude Microsoft.Authentication.WebAssembly.Msal
from trimming by including this in the client project file:
<ItemGroup>
<TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
</ItemGroup>
I had the same issue when trying to sign in. Updating Microsoft.Identity.Web and Microsoft.Identity.Web.UI to latest version(1.22.1) and then deleting the bin and obj folders solved the problem for me.
There was no need to add an ItemGroup with TrimmerRootAssembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With