fullstackhero / blazor-wasm-boilerplate

Clean Architecture Boilerplate Template for .NET 6.0 Blazor WebAssembly built for FSH WebAPI with the goodness of MudBlazor Components.

Home Page:https://fullstackhero.net/blazor-webassembly-boilerplate/general/getting-started/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] FSH.BlazorWebAssembly.Client.Shared.BaseLayout.SetCurrentTheme - Null Ref while using Azure Auth

274188A opened this issue · comments

While using AzureAd Auth I see the error (below) in the browser tools (so client side wasm) - probably due to the fact we are kind of skip showing thoese controls completely when in AzureAd Auth mode

blazor.webassembly.js:1
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at MudBlazor.Utilities.MudColor..ctor(String value)
at MudBlazor.Utilities.MudColor.op_Implicit(String input)
at FSH.BlazorWebAssembly.Client.Shared.BaseLayout.SetCurrentTheme(ClientPreference themePreference) in C:\Users\274188A\source\repos\CLEAN\WASM\blazor-wasm-boilerplate\src\Client\Shared\BaseLayout.razor.cs:line 49
at FSH.BlazorWebAssembly.Client.Shared.BaseLayout.OnInitializedAsync() in C:\Users\274188A\source\repos\CLEAN\WASM\blazor-wasm-boilerplate\src\Client\Shared\BaseLayout.razor.cs:line 24
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

I don't see this problem. What are the exact steps to reproduce? Seems to be something with your themepreference? This is something that's stored in local storage. Maybe it still has some stale data from previous versions?

steps:

  1. deleted db,
  2. insert value for Issuer into Tenant eg https://sts.windows.net/...
  3. set provider to azure on both api and wasm,
  4. run api host
  5. run wasm

exception shown once log-in negotiations completed
exception shown once log-out completed

image

Have you checked your local storage? I bet there's a null value there somewhere in your themepreference which shouldn't be there...

yeah - that was it - working ok now. I do get another exception - but I should probably close this and raise another.
image

There might be a bug somewhere how that null value got there in the first place (if it's not from doing some strange debugging stuff), but has nothing to do with AzureAd... ;-)

And that error message is probably fine... I think the signalr client always probes first without credentials, and only sends them after a 401 received.