question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

I have a simple Blazor WASM running Net 6 Preview 4 that I setup using this guide:

https://docs.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:

eod4H

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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:55 (5 by maintainers)

github_iconTop GitHub Comments

34reactions
crbrzcommented, Jun 17, 2021

The issue is caused by assembly trimming done in published version (the property LoginMode in MsalProviderOptions gets removed).

To workaround it exclude Microsoft.Authentication.WebAssembly.Msal from trimming by adding this to the client project file (tester.Client.csproj):

  <ItemGroup>
    <TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
  </ItemGroup>
11reactions
stephajncommented, Feb 2, 2022

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found