Alternatives to WebResponse/HttpWebResponse
<p>I'm trying to write a simple program to return the status code from a website. Currently using the HttpWebRequest and HttpWebResponse classes. However the way they work just seems horrible to me, the status code is only returned if its 200/OK, and all other codes give a webexception. </p>

<p>While I can read the response from the exception and get the status code I was wondering if there are any other alternatives that don't cause exceptions. As I understand exceptions are costly and should be reserved for rare occasions when there are serious problems. Not that it matters for my application but I'd rather avoid exceptions unless absolutely necessary. </p>

<p>So are there any other options?</p>

<p>Edit:</p>

<p>Here's some code</p>

<pre><code>HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create("http://www.randomsite.com");
            request.Method = "HEAD";
            try
            {
                HttpWebResponse response = (HttpWebResponse) request.GetResponse();
                Console.WriteLine("Status: " + response.StatusCode);

                response.Close();
            }
            catch (WebException ex)
            {
                HttpWebResponse httpResponse = (HttpWebResponse) ex.Response;
                if (httpResponse != null)
                {
                    Console.WriteLine("Status: " + httpResponse.StatusCode);
                }
            }
</code></pre>
