Use IHttpClientFactory (or HttpClientFactory) from a console

IHttpClientFactory is bould to Microsoft’s DI.

So create services and retrieve it.


1
2
var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();

Honour those who should be honoured.

Leave a Reply