Blazor WASM Net 6 Preview 4 Azure AD - There was an error trying to log you in: 'Cannot read property 'toLowerCase' of undefined'
See original GitHub issueI have a simple Blazor WASM running Net 6 Preview 4 that I setup using this guide:
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:55 (5 by maintainers)
Top Results From Across the Web
Blazor WASM Net 6 Preview 4 Azure AD - There was an ...
Blazor WASM Net 6 Preview 4 Azure AD - There was an error trying to log you in: 'Cannot read property 'toLowerCase' of...
Read more >Fixing Blazor WebAssembly .NET 6 MSAL authorization bug
NET 6 broke the authentication when deployed to Azure. ... TypeError: Cannot read properties of undefined (reading 'toLowerCase') at u.
Read more >[Solved]-Blazor WASM - There was an error trying to log you in ...
Blazor WASM Net 6 Preview 4 Azure AD - There was an error trying to log you in: 'Cannot read property 'toLowerCase' of...
Read more >Secure a hosted ASP.NET Core Blazor WebAssembly app ...
This article explains how to create a hosted Blazor WebAssembly solution that uses Azure Active Directory (AAD) for authentication.
Read more >Blazor + Azure ActiveDirectory B2C認証時に'Cannot read ...
Blazor + Azure ActiveDirectory B2C認証時に'Cannot read property 'toLowerCase' of undefined' エラーが出る件. C#wasmBlazorB2CActiveDirectpru.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
The issue is caused by assembly trimming done in published version (the property
LoginMode
inMsalProviderOptions
gets removed).To workaround it exclude
Microsoft.Authentication.WebAssembly.Msal
from trimming by adding this to the client project file (tester.Client.csproj):I was having this problem as well on .NET 6.0.1 using the latest version of the MSAL library. The only problem was that I wasn’t even getting any kind of error message. I would only get an empty string. Adding in the TrimRootAssembly node in my project files resolved this issue for me in multiple projects.
This issue has been open since June of 2021 and as of this writing it is February 2022. Does this mean that everyone who runs .NET 6 Blazor WASM and tries to do a Release build is having this problem? Shouldn’t something like this have been fixed before .NET 6 went to RTM? Even more so, shouldn’t it have been prioritized for the 6.0.1 release?
Or will this become part of the standard project file template if you decide to use MSAL when creating a new project?