HTTP POST Returns Error: 417 “Expectation Failed.”

When I try to POST to a URL it results in the following exception: The remote server returned an error: (417) Expectation Failed. Here’s a sample code: var client = new WebClient(); var postData = new NameValueCollection(); postData.Add(“postParamName”, “postParamValue”); byte[] responseBytes = client.UploadValues(“http://…”, postData); string response = Encoding.UTF8.GetString(responseBytes); // (417) Expectation Failed. Using an HttpWebRequest/HttpWebResponse … Read more

How to change the timeout on a .NET WebClient object

I am trying to download a client’s data to my local machine (programatically) and their webserver is very, very slow which is causing a timeout in my WebClient object. Here is my code: WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; webClient.DownloadFile(downloadUrl, downloadFile); Is there a way to set an infinite timeout on this object? … Read more