Do pooled HttpClient instances keep the CookieContainer? Because the HttpClientFactory creates a new HttpClient with each request for a client, you can add to the headers of the client and not worry about it reusing the cookie The key to doing this is the setting UseCookies It HAS to be set to false or the cookies you add to the headers will be ignored
HttpClient guidelines for . NET - . NET | Microsoft Learn Using more than one instance is necessary for scenarios with multiple proxies or to separate cookie containers without completely disabling cookie handling Using IHttpClientFactory, you can have multiple, differently configured clients for different use cases
C# - HttpClient not storing cookies in CookieContainer Ensure that you reuse the same HttpClient instance throughout your application and that you configure its HttpClientHandler (or custom HttpMessageHandler) appropriately to enable cookie handling
Do pooled HttpClient instances keep the CookieContainer? When you use the same instance of HttpClient for multiple requests (sequential and concurrent) to the same URL, it'll reuse connections Requests that get to reuse a connection are 5 5-8 5x faster than requests that have to open a new connection
C# tutorials : How to handle cookies and sessions in HTTP? This tutorial explains how to manage cookies and sessions in C# using NET's `HttpClient` for handling HTTP requests We'll cover sending cookies, retrieving cookies, and implementing basic session management
A better way to manage cookies and session for HttpClient Today you have to either always turn the cookies off and potentially track them manually, or to create several HttpClients and carefully manage their lifetime and usages -- there're no good workarounds