Recently in C # call Java Write WebService, found always return 500 server error, exactly what reason has not been found out,
After Google later, to find a foreign http://stackoverflow.com site has been encountered this problem.
Reprint as follows:
HttpWebRequest req = webrequest.create (URL) as HttpWebRequest; WebResponse WR = req. GetResponse ();
When the server returns Internal server Error, exception was thrown in req. GetResponse (). I would like the GetResponse () to accept this Response code, it's normal for the passed URL to throw this Response code. I would like to parse the Html despite Response Code Internal Server Error. Is it possible to say to GetResponse () method does not verify the Response Code?
Answer:
try{ HttpWebRequest req = webrequest.create (URL) as HttpWebRequest; WebResponse WR = req. GetResponse ();} catch (WebException Wex) { var pagecontent = new StreamReader (Wex. Response.getresponsestream ()) . ReadToEnd ();}
The above code can be used to query the specific error message, and then further solve the problem.
Original address:
Http://stackoverflow.com/questions/18403846/httpwebrequest-accept-500-internal-server-error