2

I throw an error in my REST service like:

throw new WebFaultException<String>("bla bla bla",
   HttpStatusCode.HttpVersionNotSupported);

but when I try to get the error content in

var r = (HttpWebResponse)(request.GetResponse());
if (r.StatusCode != HttpStatusCode.OK) {...

The problem is that GetResponse() throws a WebException error. And it is impossible for me to get the "bla bla bla" text. How can I get this text? The web exception contains the status code HttpVersionNotSupported but no property that contains the text "bla bla bla". Where is the data I send as first parameter of WebFaultException?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Ryan
  • 5,456
  • 25
  • 71
  • 129

1 Answers1

0

Try using the HttpWebResponse.GetResponseStream method to access the contents of the response. The sample code in the link should you show how to read and clean up the stream.

Sixto Saez
  • 12,610
  • 5
  • 43
  • 51