0

Calling GetResponse() on an httpWebRequest, In all my testing i saw that this call throws WebException when the request fail.

My question is why is there a StatusCode property on the HttpWebResponse ? It seems that the GetResponse() call will only return responses with status code 200 and throw otherwise.

And should i even bother looking if the StatusCode is not 200 ? Assuming the only thing i can do with this information is throw exception myself ...

abatishchev
  • 98,240
  • 88
  • 296
  • 433
MichaelB
  • 1,332
  • 1
  • 15
  • 29

1 Answers1

1

The entire 2xx range means that the operation has completed successfully. Status code 201 for instance, indicates that a new resource has been created.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for a list of all common status codes.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72