With this code I get the response (error code and message) when an exception from type WebException gets catched.
Dim castExceptionToWebException As WebException = TryCast(ex, WebException)
using r As new StreamReader(castExceptionToWebException.Response.GetResponseStream())
Dim responseContent = r.ReadToEnd()
' DO SOMETHING WITH responseContent
End Using
My questions are: 1.) How could I get the response stream like I did but without casting down to WebException? Is it possible to access it through Exception class 2.) Is there any better work-around?