When I create a new Blazor WebAssembly Standalone project, it automatically adds an HttpClient
in Program.cs
-- see below:
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
Is this necessary and used by the WebAssembly app or is it Microsoft's way of "making my life easier"?
P.S. The question was closed because it was deemed opinion based. It is not at all opinion based. It simply asks whether the HttpClient
declared in Program.cs
is used by WebAssembly app or not.
Yes, it's just being 'helpful' on the assumption that you'd want to be calling an API somewhere from your WebAssembly app.
If you're not making any API calls you can safely remove it.