How can I change the time limit for webClient.UploadData()?

The WebClient doesn’t have a timeout property, however it is possible to inherit from the WebClient to give access to Timeout on the internal WebRequest used:

 public class WebClientEx : WebClient
 {
     public int Timeout {get; set;}

     protected override WebRequest GetWebRequest(Uri address)
     {
        var request = base.GetWebRequest(address);
        request.Timeout = Timeout;
        return request;
     }
 }

Usage:

 var myClient = new WebClientEx();
 myClient.Timeout = 900000 // Daft timeout period
 myClient.UploadData(myUri, myData);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)