下面的代碼:我怎樣才能從餅乾HttpClientHandler.CookieContainer
public static async Task<string> DownloadPageWithCookiesAsync(string url)
{
HttpClientHandler handler = new HttpClientHandler();
handler.UseDefaultCredentials = true;
handler.AllowAutoRedirect = true;
handler.UseCookies = true;
handler.CookieContainer = new CookieContainer();
HttpClient client = new HttpClient(handler);
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = response.Content.ReadAsString();
return responseBody;
}
的client.GetAsync(url);
運行後,handler.CookieContainer
包含7塊餅乾。我如何訪問它們?
'foreach語句無法在類型「System.Net.CookieContainer」的變量操作,因爲「System.Net.CookieContainer」不包含「GetEnumerator'' –
使用for循環而不是一個公共定義抓住他們? –
感謝但循環在什麼?沒有定義索引運算符。 –