Downloading file from HTTPS works from browser but not from C#
I have a problem with downloading file from HTTPS. Server is 3rd party and
it's providing TXT transaction data to download (something like
https://blabla.dat). Validation using IP address (from invalid IP you get
403 error). From browser (IE, Mozilla) download works perfectly but from
C# a get timeout...
I used to set
ServicePointManager.ServerCertificateValidationCallback = delegate {
return true; };
and then download the file...
WebClient webClient = new WebClient();
webClient.DownloadFile(url, dest);
and it works for some HTTPS (like images from HTTPS Facebook) but not in
my case. (weird)
I also tried to set Credentials and Header (no change).
webClient.Credentials = CredentialCache.DefaultNetworkCredentials;
webClient.Proxy = WebRequest.DefaultWebProxy;
webClient.Proxy.Credentials = CredentialCache.DefaultCredentials;
webClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
How can I download this file? Something like simulating IE request and
accept certificate??? I'm new to this kind of issues. Thank you very much!
No comments:
Post a Comment