HttpWebRequest: The request was aborted: The request was canceled

The common solution listed on the Internet appears to be to set the KeepAlive property of the HttpWebRequest to false. This can resolve the problem if the root cause is that the connection is expected to be reused even though it was actually closed automatically after some period of time. However, there is a performance hit to constantly opening and closing connections.

Another possible solution that I used when I encountered this problem was to extend the Timeout properties: WebRequest.ReadWriteTimeout, WebRequest.Timeout, RequestStream.WriteTimeout, and RequestStream.ReadTimeout. Please note these are in milliseconds, so you may want the timeouts to be 1000 * 60 * 10 to represent 10 minutes (or just 600000 if you think you will know what that means…). You can test if this is the more likely cause of the problem by reducing the file size.

BTW. Your code wasn’t on the listed website anymore. You may want to include it in the text of your post if it is still an issue.

Leave a Comment