I am reading data from a website as follows:
webRequestObj = (HttpWebRequest)WebRequest.Create("http://localhost/503errorPage.php");
theResponse = webRequestObj.GetResponse();
theResponseStream = theResponse.GetResponseStream();
theStreamReader = new StreamReader(theResponseStream);
theWholePage = theStreamReader.ReadToEnd();
If I get to a page that has a 503 error, the line:
theResponse = webRequestObj.GetResponse();
throws a WebException:
The remote server returned an error: (503) Server Unavailable.
Is there a way check if the website returns a 503 error instead of wrapping everything up in a try/catch block and waiting for the exception? I am doing many updates per second and would like to avoid the try/catch if possible.