Issue with Blazor WASM not returning to ReturnUrl after Sign-In


I’m using Auth0 in a Blazor WASM application. Everything works like I would expect, except the user is not redirected to their previous page after logging in. For example, if the user goes to the page: and clicks “Log In”, after they are logged in they are redirected to instead of This is a big issue, as it makes sending direct links to content on the site that requires authorization useless.

I had this issue in my main app and couldn’t solve it, so I started a new app based off of the Auth0 Blazor Wasm template. I removed the server portion (as I am using Wasm only), upgraded it to .NET 8.0, and changed the AccessControl.razor as follows:

@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using System.Diagnostics

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

        Hello, @context.User.Identity.Name!
        <a href="#" @onclick="BeginSignOut">Log out</a>
        <a href="#" @onclick="BeginSignIn">Log in</a>

    private async Task BeginSignOut(MouseEventArgs args)
        await SignOutManager.SetSignOutState();

    private void BeginSignIn()
        InteractiveRequestOptions requestOptions = new()
            Interaction = InteractionType.SignIn,
            ReturnUrl = Navigation.Uri,

        Navigation.NavigateToLogin($"authentication/login", requestOptions);


The only significant change being using the InteractiveRequestOptions with a ReturnUrl that are required for .Net 7 and up.

This setup works (user is redirected after login correctly) when running and debugging on localhost, but as soon as I publish it anywhere (Azure Static Site, Azure App Service, Static Webhost, etc) I have the issue described above where I am not redirected properly.

Does anyone know what could be the issue?


Running into the exact same issue for a Blazor WASM app on .NET 8. My use case is related to a login redirect when the user navigates to a page they are not authorized to view, but my login redirect code is almost identical to above. Works fine locally, but in deployed environments the redirect does not seem to be working at all. Also tried using the template application and seeing the same behavior.

Any guidance/solutions would be appreciated.


Same problem here on NET 8!

Try adding this line to your Blazor Project

<TrimmerRootAssembly Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" />

I think it fixed my issue.


I tried this out and it worked for me too, thank you for sharing!

Was this just something that you tried, or did you see a link about it? I’m curious if this is a bug or what.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.