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

**URL:** <https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [February 26, 2024, 2:18pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335 "2024-02-26T14:18:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam16](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@adam16](https://community.auth0.com/u/adam16)\
**Post date:** [February 26, 2024, 2:18pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/1 "2024-02-26T14:18:47Z")

</div>

Hello,

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: [example.com/counter](http://example.com/counter) and clicks “Log In”, after they are logged in they are redirected to [example.com](http://example.com) instead of [example.com/counter](http://example.com/counter). 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:

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

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

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

@code{
    private async Task BeginSignOut(MouseEventArgs args)
    {
        await SignOutManager.SetSignOutState();
        Navigation.NavigateTo("authentication/logout");
    }

    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?

---

<div class="post-metadata">

**Author:** ![skuloor](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@skuloor](https://community.auth0.com/u/skuloor)\
**Post date:** [February 29, 2024, 3:14pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/2 "2024-02-29T15:14:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![drmaven](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/drmaven/32/48947_2.png) [@drmaven](https://community.auth0.com/u/drmaven)\
**Post date:** [February 29, 2024, 5:51pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/3 "2024-02-29T17:51:40Z")

</div>

Same problem here on NET 8!

---

<div class="post-metadata">

**Author:** ![drmaven](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/drmaven/32/48947_2.png) [@drmaven](https://community.auth0.com/u/drmaven)\
**Post date:** [March 1, 2024, 9:13am UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/5 "2024-03-01T09:13:11Z")

</div>

Try adding this line to your Blazor Project

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

I think it fixed my issue.

---

<div class="post-metadata">

**Author:** ![adam16](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@adam16](https://community.auth0.com/u/adam16)\
**Post date:** [March 1, 2024, 2:55pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/6 "2024-03-01T14:55:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 15, 2024, 2:55pm UTC](https://community.auth0.com/t/issue-with-blazor-wasm-not-returning-to-returnurl-after-sign-in/128335/7 "2024-03-15T14:55:59Z")

</div>

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