public static GetResponseBody ( this ex ) : string | ||
ex | this | |
return | string |
public static string GetResponseBody(this Exception ex)
{
var webEx = ex as WebException;
if (webEx == null || webEx.Status != WebExceptionStatus.ProtocolError) return null;
var errorResponse = ((HttpWebResponse)webEx.Response);
using (var reader = new StreamReader(errorResponse.GetResponseStream()))
{
return reader.ReadToEnd();
}
}