Skip to content

Blazor WASM hosted with IndividualB2C: Choose layout based on authentication state  #29411

@jaldinger

Description

@jaldinger

I have tried to implement the solution explained in this issue and SteveSandersonMS answer:

Originally posted by @SteveSandersonMS in #26122 (comment)

But this solution seems to prevent the RedirectToLogin component from working, with the following error whenever accessing a page with the [Authorize] attribute set:

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 Microsoft.AspNetCore.Components.WebAssembly.Authentication.AuthorizationMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
at System.Net.Http.Json.HttpClientJsonExtensions.d__9`1[[BlazorPortal.Shared.WeatherForecast[], BlazorPortal.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
at BlazorPortal.Client.Pages.FetchData.OnInitializedAsync() in C:\Users\JoergAldinger\source\repos\BlazorPortal\Client\Pages\FetchData.razor:line 48
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Is there anything that can be done to get the redirect to work with this scheme?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions