0

需要使用 httpclientfactory 的等效代码

CookieContainer cookies = new CookieContainer(); 
HttpClientHandler handler = new HttpClientHandler(); 
handler.CookieContainer = cookies; 
HttpClient client = new HttpClient(handler); 
HttpResponseMessage response = client.GetAsync("http://google.com").Result; 
Uri uri = new Uri("http://google.com"); 
IEnumerable<Cookie> responseCookies = cookies.GetCookies(uri).Cast<Cookie>(); 

foreach (Cookie cookie in responseCookies) 
    Console.WriteLine(cookie.Name + ": " + cookie.Value);
4

0 回答 0