HttpWebRequest ->HttpWebResponse question

G

Guest

Hi...

I ran into an odd circumstance using HttpWebRequest. Specifically, when you
call GetResponse() it throws a WebException, to quote the msdn page,
Abort was previously called.
-or-
The time-out period for the request expired.
-or-
An error occurred while processing the request.

The last item is the part I find quizzical. "An error occurred while
processing the request" appears to cover any non-200 return status while
ignoring that, say, a 404 or a 500 status *can* have a payload that is of
interest. A custom error page, or a 500-page might have information about
what went wrong.

Is there any way to get ahold of the payload when the return status is not
200? GetResponse errors out, and I can't find a property to stop that.

Thanks
-Mark
 
D

David Browne

Mark said:
Hi...

I ran into an odd circumstance using HttpWebRequest. Specifically, when
you
call GetResponse() it throws a WebException, to quote the msdn page,
Abort was previously called.
-or-
The time-out period for the request expired.
-or-
An error occurred while processing the request.

The last item is the part I find quizzical. "An error occurred while
processing the request" appears to cover any non-200 return status while
ignoring that, say, a 404 or a 500 status *can* have a payload that is of
interest. A custom error page, or a 500-page might have information about
what went wrong.

Is there any way to get ahold of the payload when the return status is not
200? GetResponse errors out, and I can't find a property to stop that.

GetResponse will throw a WebException, but the response is attached to the
WebException, and available in the WebException.Response property.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top