How to stop .Net HttpWebRequest.GetResponse() raising an exception
Posted
by James
on Stack Overflow
See other posts from Stack Overflow
or by James
Published on 2010-04-23T21:29:02Z
Indexed on
2010/04/23
21:33 UTC
Read the original article
Hit count: 344
Surely, surely, surely there is a way to configure the .Net HttpWebRequest object so that it does not raise an exception when HttpWebRequest.GetResponse() is called and any 300 or 400 status codes are returned?
Jon Skeet does not think so, so I almost dare not even ask, but I find it hard to believe there is no way around this. 300 and 400 response codes are valid responses in certain circumstances. Why would we be always forced to incur the overhead of an exception?
Perhaps there is some obscure configuration setting that evaded Jon Skeet? Perhaps there is a completely different type of request object that can be used that does not have this behavior?
(and yes, I know you can just catch the exception and get the response from that, but I would like to find a way not to have to).
Thanks for any help
© Stack Overflow or respective owner