Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to configure HttpClient base address in Blazor Server using IHttpClientFactory

$
0
0

I am trying to configure HttpClient's base address in a Blazor Server using IHttpClientFactory but I am getting a runtime exception:

    services.AddHttpClient("ApiClient", (provider, client) =>    {        var uriHelper = provider.GetRequiredService<NavigationManager>();        client.BaseAddress = new Uri(uriHelper.BaseUri);    });
System.InvalidOperationException: 'Cannot resolve scoped service 'Microsoft.AspNetCore.Components.NavigationManager' from root provider.'

Exception screenshot

Anyone know what might be the issue here?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>