I am trying to upload a long video to jwplatform with the help of HttpWebRequest.I have set the Timeout as below . when i upload data it throw error.
The request was aborted: The operation has timed out
Event though the server timeout is along enough to weight for response but i still returning the same error.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(callUrl);
request.ContentType = "multipart/form-data; boundary=" +
boundary;
request.Method = "POST";
request.KeepAlive = true;
request.Timeout= 24*60*60*1000;
...
using (var response = request.GetResponse())
{
Stream stream2 = response.GetResponseStream();
StreamReader reader2 = new StreamReader(stream2);
res = reader2.ReadToEnd();
}
I am using the GetResponse() mathod as above.
Any help on how i can force the webrequest to wait until the data is fully upload will be highly appreciated. Thanks in Advance.
You can use
request.GetResponseAsync ().and so use asynchronous task to wait properly the response.To help you, it'll be something like this :