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

Re: HttpWebRequest ->HttpWebResponse question by David

David
Wed Mar 23 15:20:17 CST 2005


"Mark" <mmodrall@nospam.nospam> wrote in message
news:9804415D-4A02-4C46-9F44-D63B9A7C5DFA@microsoft.com...
> 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



Re: HttpWebRequest ->HttpWebResponse question by mmodrall

mmodrall
Thu Mar 24 11:19:08 CST 2005

Thanks, David! That did the trick...

-Mark