title: .NET 5 Blazor HttpClient BaseAddressAuthorizationMessageHandler not found
body: <p>I am trying to add Authentication to my .NET 5 Blazor WASM application using <a href="https://chrissainty.com/securing-your-blazor-apps-authentication-with-clientside-blazor-using-webapi-aspnet-core-identity/" rel="nofollow noreferrer">this article</a> and I am getting an error</p>
  <p><code>Unhandled exception rendering component: No service for type 'Microsoft.AspNetCore.Components.WebAssembly.Authentication.BaseAddressAuthorizationMessageHandler' has been registered.</code></p>
  <p>I downloaded the sample from the git <a href="https://github.com/chrissainty/AuthenticationWithClientSideBlazor" rel="nofollow noreferrer">here</a>, ran it and everything worked, then I noticed that the sample was done in .NET 3 and when I updated it to run on .NET 5 the same error is creeping up. In my <code>Program.cs</code> I registered the <code>HttpClient</code> and the <code>BaseAddressAuthorizationMessageHandler</code> like so</p>
  <pre><code>  public static async Task Main(string[] args)
    {
       var builder = WebAssemblyHostBuilder.CreateDefault(args);
       builder.RootComponents.Add&lt;App&gt;(&quot;app&quot;);
  
       builder.Services.AddHttpClient(&quot;ServerAPI&quot;,
          client =&gt; client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
       .AddHttpMessageHandler&lt;BaseAddressAuthorizationMessageHandler&gt;();
  
       builder.Services.AddScoped(sp =&gt; sp.GetRequiredService&lt;IHttpClientFactory&gt;()
           .CreateClient(&quot;ServerAPI&quot;));
  
       builder.Services.AddBlazoredLocalStorage();
       builder.Services.AddAuthorizationCore();
       builder.Services.AddScoped&lt;AuthenticationStateProvider, ApiAuthenticationStateProvider&gt;();
       builder.Services.AddScoped&lt;IAuthService, AuthService&gt;();
  
       await builder.Build().RunAsync();
    }
  </code></pre>
  <p>I think this is a false error, as you can see I am adding the <code>BaseAddressAuthorizationMessageHandler</code> to the client just as it shows <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/additional-scenarios?view=aspnetcore-5.0" rel="nofollow noreferrer">here</a>, is there something I am missing? Is there a namespace I need to import or is there another part of the configuration missing? Breakpoints don't seem to work in the client's <code>Program.cs</code> and I don't see any other errors that could explain this.</p>