title: Blazor WASM stuck on "Authorizing..." and "Completing login..."
body: <p>After upgrading to .Net 5.0 my blazor WASM app started getting stuck on &quot;Authorizing...&quot; (it gets stuck when the user was already logged in, first load with redirect to login screen works fine, so I have to clear the cache if I want it to work) and &quot;Completing login...&quot; (with a URL like https://localhost:5001/authentication/login-callback?code=51FEF78805049242F1092A249B1746393790AE956B1FC2136092AE0924B3FB42&amp;scope=openid%20profile%20email%20MyApp.WebAPI&amp;state=e8bffbd2b93f44dc8a261cf6d65c6165&amp;session_state=eE0yRtJI0fkjptvZSIfiUsvuHAQoyNStmS_kv--Wcv0.DCACB551F4CC63841C2615456DD4B9BF) - if I go to localhost:5001 after it got stuck on &quot;Completing login...&quot; I am finally logged in.</p>
  <p>Initially it was working fine on most modern computers and the issue was only visible on slow computers (~8 year old laptop for instance). However, while I tried to understand the issue and fix it, I managed to brake it completely on my developer laptop as well, where the main branch still works mostly fine.</p>
  <p>Creating a new ASP.Net Core app with authentication with IdentityServer4 works just fine, no issues there.</p>
  <p>My issue looks similar to <a href="https://github.com/dotnet/aspnetcore/issues/26195" rel="nofollow noreferrer">https://github.com/dotnet/aspnetcore/issues/26195</a> - however, I'm using only IdentityServer4 and I don't see any exceptions in the developer console.</p>
  <p>I tried to reduce the code to a bare minimum, so here is the <code>Program.cs</code>:</p>
  <pre class="lang-cs prettyprint-override"><code>public static async Task Main(string[] args)
  {
      var builder = WebAssemblyHostBuilder.CreateDefault(args);
      builder.RootComponents.Add&lt;App&gt;(&quot;#app&quot;);
  
      builder.Services.AddApiAuthorization();
  
      builder.Services.AddSingleton&lt;IStringLocalizer&gt;(serviceProvider =&gt;
      {
          var factory = serviceProvider.GetRequiredService&lt;IStringLocalizerFactory&gt;();
          return factory.Create(typeof(SharedResource));
      });
      builder.Services.AddLocalization();
  
      builder.Services
          .AddBlazorise()
          .AddBootstrapProviders();
  
      builder.Logging.SetMinimumLevel(LogLevel.Trace);
  
      var host = builder.Build();
  
      host.Services.UseBootstrapProviders();
  
      await host.RunAsync();
  }
  </code></pre>
  <p>the <code>App.razor</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>@inject IStringLocalizer S
  
  &lt;ThemeManager&gt;
      &lt;CascadingAuthenticationState&gt;
          &lt;Router AppAssembly=&quot;@typeof(App).Assembly&quot; PreferExactMatches=&quot;@true&quot;&gt;
              &lt;Found Context=&quot;routeData&quot;&gt;
                  &lt;AuthorizeRouteView RouteData=&quot;@routeData&quot; DefaultLayout=&quot;@typeof(MainLayout)&quot;&gt;
                      &lt;NotAuthorized&gt;
                          @if (context.User.Identity?.IsAuthenticated ?? false)
                          {
                              &lt;p&gt;@S[&quot;You don't have enough permissions to access this page.&quot;]&lt;/p&gt;
                          }
                          else
                          {
                              &lt;RedirectToLogin /&gt;
                          }
                      &lt;/NotAuthorized&gt;
                  &lt;/AuthorizeRouteView&gt;
              &lt;/Found&gt;
              &lt;NotFound&gt;
                  &lt;LayoutView Layout=&quot;@typeof(MainLayout)&quot;&gt;
                      &lt;NotFoundError&gt;
                      &lt;/NotFoundError&gt;
                  &lt;/LayoutView&gt;
              &lt;/NotFound&gt;
          &lt;/Router&gt;
      &lt;/CascadingAuthenticationState&gt;
  &lt;/ThemeManager&gt;
  </code></pre>
  <p>The <code>MainLayout.razor</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>@inherits Microsoft.AspNetCore.Components.LayoutComponentBase
  
  &lt;header&gt;
  &lt;/header&gt;
  
  &lt;main&gt;
      @Body
  &lt;/main&gt;
  </code></pre>
  <p>The <code>Authentication.razor</code>:</p>
  <pre class="lang-xml prettyprint-override"><code>@page &quot;/authentication/{action}&quot;
  @using Microsoft.AspNetCore.Components.WebAssembly.Authentication
  &lt;RemoteAuthenticatorView Action=&quot;@Action&quot; /&gt;
  
  @if (Action == &quot;logged-out&quot;)
  {
      &lt;RedirectToLogin RedirectBackToRoot=&quot;true&quot;&gt;&lt;/RedirectToLogin&gt;
  }
  
  @code{
      [Parameter]
      public string? Action { get; set; }
  }
  </code></pre>
  <p>The problem is, that it just gets stuck and I don't even see what could be wrong. The one dependency I have here is on <a href="https://github.com/stsrki/Blazorise" rel="nofollow noreferrer">https://github.com/stsrki/Blazorise</a> - however, I added the same dependency also to the new application, and that one still works.</p>
  <p>Any idea how I could identify the issue?</p>