Read Web Request Message during 500-Internal Server Error |
|
How to parse and get the “HttpWebRequest” response message when the response status is “500 Internal Server Error”?
|
sivasankari4gl |
Answered# (1)
|
Reply For This Question
|
|
|
Answer(s) Posted
|
|
Read Web Request Message during 500-Internal Server Error
|
|
By reading the response stream of exception, inner message can be retrieved. Below given the code snippet.
catch (WebException webEx)
{
string exMessage = webEx.Message;
if (webEx.Response != null)
{
using (var responseReader = new StreamReader(webEx.Response.GetResponseStream()))
{
exMessage = responseReader.ReadToEnd();
}
}
//exMessage --> Exception Inner Message.
}
|
Karthik G
| Answered# (1)
|
|
|
Post Your Answer
|
Please login to post your answer.
|
|
|