I am using C# WebClient to get a server response and i get this exception message :
The remote server returned an error: (403) Forbidden.
this is right page response code is 403 but there is additional response message i need to read. this response message is the same i get when i access the server from a web browser.
The first image is showing HTTP headers in chrome. and the second one shows the response.
what i am asking for is how to get this text/plain response message ?
Catch the WebException and read its Response property:
try
{
request.GetResponse();
}
catch (WebException e)
{
if (e.Response != null)
return getResponseBody(e.Response);
else
throw;
}