Вы не можете получить его из webclient, однако в своем WebException вы можете получить доступ к объекту Response Object, который будет включен в объект HttpWebResponse, и вы сможете получить доступ ко всему объекту ответа.
Для получения дополнительной информации см. Определение класса WebException.
Ниже приведен пример из MSDN (не самый лучший способ для обработки исключения, но это должно дать вам некоторое представление)
try {
// Create a web request for an invalid site. Substitute the "invalid site" strong in the Create call with a invalid name.
HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create("invalid site");
// Get the associated response for the above request.
HttpWebResponse myHttpWebResponse = (HttpWebResponse) myHttpWebRequest.GetResponse();
myHttpWebResponse.Close();
}
catch(WebException e) {
Console.WriteLine("This program is expected to throw WebException on successful run."+
"\n\nException Message :" + e.Message);
if(e.Status == WebExceptionStatus.ProtocolError) {
Console.WriteLine("Status Code : {0}", ((HttpWebResponse)e.Response).StatusCode);
Console.WriteLine("Status Description : {0}", ((HttpWebResponse)e.Response).StatusDescription);
}
}
catch(Exception e) {
Console.WriteLine(e.Message);
}
Этот вопрос может помочь: http://stackoverflow.com/questions/7036491/get-webclient-errors-as-string –
И это http://stackoverflow.com/ вопросы/11828843/c-sharp-webexception-how-to-get-whole-response-with-a-body – I4V