C# web request method with url and process the stream
<p>How would you use this web request method?:</p>

<pre><code>        try
        {
            var request = WebRequest.Create(uri);
            using (var response = request.GetResponse())
            {
                using (var responseStream = response.GetResponseStream())
                {
                    // Process the stream
                }
            }
        }
        catch (WebException ex)
        {
            if (ex.Status == WebExceptionStatus.ProtocolError &amp;&amp;
                ex.Response != null)
            {
                var resp = (HttpWebResponse)ex.Response;
                if (resp.StatusCode == HttpStatusCode.NotFound)
                {
                    // Do something
                }
                else
                {
                    // Do something else
                }
            }
            else
            {
                // Do something else
            }
        }
    }
</code></pre>

<p>I found the above code on a website and I'm not sure what process the stream means or where you put the url :ex: <a href="http://www.google.com" rel="nofollow">http://www.google.com</a> I prefer to use this code instead but I can't get else statements to work with it, and that is what I need.</p>

<pre><code>        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("URL", hashe));
        try
        {
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        }
        catch (Exception ex)
        {
            if (ex.ToString().Contains("404"))
            {

            }
        }
</code></pre>
