The remote server returned an error (500) internal server error httpwebrequest.

Hello Friends,

I am writing this because I have spend valuable time to resolve this "Web Service" error.  Actually the web service was working fine. But when I submitting the data from my website it is continuously giving  "(500) internal server error httpwebrequest".

Actually It was an internal error of web service when I was submitting the invalid data. To resolve that you need to first get that exception which is thrown by web service with the following code:


try
{
   HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;

   WebResponse wr = req.GetResponse();
}
catch (WebException wex)
{
   var pageContent = new StreamReader(wex.Response.GetResponseStream())
                         .ReadToEnd();
}
This catch blocks gives you the actual error thrown by web service instead of "(500) internal server error httpwebrequest".

Comments