title: Is there a way to change HttpWebRequest behavior on 400/500 status codes?
body: <p>I am working on building a fluent REST client interface on top of the <code>HttpWebRequest</code>/<code>HttpWebResponse</code> types in .NET. So far, so good...however I am trying to develop a pluggable security framework that can automatically handle security token negotiation, token refreshes, etc. </p>
  
  <p>I've run into a problem due to the nature of how <code>HttpWebRequest/Response</code> work when they encounter a 400 series or 500 series HTTP status code. Rather than simply setting the <code>.StatusCode</code> and <code>.StatusDescription</code> properties and allowing you to handle in whatever way you wish, they throw a <code>WebException</code>. Generally speaking, this probably isn't a problem...however the way we are authenticating (derivative of OAuth 2.0), I need to handle certain 400 series errors without an exception occurring.</p>
  
  <p>Is there some way to reconfigure HttpWebRequest/Response to NOT throw <code>WebException</code>, and allow the consumer to determine their own error handling? I know that there are some round-about ways of handling Expect-100-Continue with older Http1.0 servers...I'm curious if there is a similar round-about way to disable WebExceptions.</p>
  
  <p>(Oh, and just can't resist...a BIG OL' SHOUT OUT to my WONDERFUL friends over at RedGate for illegally taking away the license-bound FREE version of Reflector 6...I might be able to figure this one out on my own if I could snoop the code...but alas...Reflector is sadly an nonviable option now that it has consumed itself via autolysis. ;P )</p>