Tag: webrequest

WebClient with Timeout Support

Author: | Categories: Programming No Comments
By default the C# WebClient class does not let you modify the default timeout value of 1 minute. This subclass exposes the Timeout property so you can change the default without having to use a HttpWebRequest. using System; using System.Net; namespace MyNamespace { public class WebClientEx : WebClient { public int Timeout { get; set; […]

HTTP Status Code in case of Exception

Author: | Categories: Programming No Comments
This is how to get HTTP Status code in case of an Exception during HttpWebRequest catch(WebException ex) { HttpWebResponse res = (HttpWebResponse) ex.Response; Console.WriteLine("Http status code: " + res.StatusCode); }