HttpWebRequest ->HttpWebResponse question

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top