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

How do I register HTTP client in Blazor .NET 8?

$
0
0

I am used to registering the httpclient in the program.cs of the client project as follows

builder.Services.AddHttpClient("My.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))    .AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();

However this does not work in Blazor .net8. I get errors saying that there is

InvalidOperationException: Cannot provide a value for property 'Http'on type 'My.Client.Pages.RiskReview'. There is noregistered service of type 'System.Net.Http.HttpClient'.

What do I need to do to register the httpclient in blazor .net 8?

I am using webassembly rendering


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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