Tôi muốn tải pdf với WebClient
nhưng tôi cần gửi cookie với yêu cầuthêm cookie WebClient
Làm thế nào có thể thêm cookie WebClient
sau đó tải pdf
WebClient webClient = new WebClient();
webClient.DownloadFile("http://........", "C://2.pdf");
Tôi muốn tải pdf với WebClient
nhưng tôi cần gửi cookie với yêu cầuthêm cookie WebClient
Làm thế nào có thể thêm cookie WebClient
sau đó tải pdf
WebClient webClient = new WebClient();
webClient.DownloadFile("http://........", "C://2.pdf");
Bạn có thể thêm cookie vào webClient.
webClient.Headers.Add(HttpRequestHeader.Cookie, "cookies");
webClient.DownloadFile("http://........", "C://2.pdf");
WebClient
không hỗ trợ cookie. Bạn cần tự thêm hỗ trợ cho các cookie ghi đè GetWebRequest
hoặc chỉ cần sử dụng lớp HttpWebRequest
.
Dunno nếu điều này là sự thật trong quá khứ, nhưng WebClient không hỗ trợ cookie ngày hôm nay. xem, ví dụ: -http: //stackoverflow.com/questions/12537064/httprequestheader-cookie-format – FuzzyAmi
Hoặc sử dụng HttpWebRequest hoặc lớp WebClient và ghi đè 'GetWebRequest'' GetWebResponse' –