I have the below code that I wish to transfer over to a .NET 6 Core.
HttpClientHandler handler = new HttpClientHandler();
HttpClient client = new HttpClient(handler);
CookieContainer cookieContainer = new CookieContainer();
// Setup the cookie container
handler.CookieContainer = cookieContainer;
But instead of newing up the HttpClient
, I want to use the HttpClientFactory
. However, I can't figure how to use the HttpClientFactory
with an existing instance of the HttpClientHandler
.
I need the instance of the handler, since I use it with the CookieContainer
.
I don't care if I use a DI instance of the HttpClientFactory
, or if I can create the HttpClient
instance directly in my Program.cs
.
Any help would be appreciated. Thank you.