.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is return

Posted by chefsmart on Stack Overflow See other posts from Stack Overflow or by chefsmart
Published on 2009-03-28T06:40:02Z Indexed on 2010/04/20 15:33 UTC
Read the original article Hit count: 685

Filed under:
|

I am in a situation where when I get an HTTP 400 code from the server, it is a completely legal way of the server telling me what was wrong with my request (using a message in the HTTP response content)

However, the .NET HttpWebRequest raises an exception when the status code is 400.

How do I handle this? For me a 400 is completely legal, and rather helpful. The HTTP content has some important information but the exception throws me off my path.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about httpwebrequest