HttpWebRequest avoiding an error (500)
<p>I'm using webservice to call other services. And I have to call many services with loop.</p>

<p>Now the problem is when some services didn't available, the loop was broke.</p>

<pre><code>HttpWebRequest request = WebRequest.Create(stringBuilder.ToString()) as HttpWebRequest;
request.ContentType = "application/json; charset=utf-8";
request.Credentials = CredentialCache.DefaultCredentials;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode != HttpStatusCode.OK)
{
    continue;
}
</code></pre>

<p>when the services didn't available(Error 500) it's broken before I have checked statusCode.</p>

<p>Error at <code>response = (HttpWebResponse)request.GetResponse();</code></p>

<p>How can I check the error and continue to call with the other services?</p>
