How to avoid WebException in a GetResponse() method?

Create a simple function with the try/catch statements and call it instead.

If you read the answer, I say that I want to check if the webRequest exist, I want to avoid the exception so, this answer is not valid. Please, delete it. – Daniel Peñalba Nov 11 at 14:04 @DanielPeñalba, why don't you simply create a method (or extension method) that does exactly that: DoesTargetExist.It only needs to contain a try/catch, inside the catch you return false, at the end of the try you return true.

To prevent downloading the whole picture, use WebClient, OpenStream en Read. – Abel Nov 11 at 15:31.

Then indeed, mark to ignore it in the debugger settings. If not, and if you can change your server behavior, then you probably can program a web-service there which will return you an indication of file existence on the server.HttpWebRequest.GetResponse() will throw an exception anyway.Do not use HttpWebRequest class if you do not like this behavior.

I need something to check if the webrespose exists. – Daniel Peñalba Nov 11 at 14:06 If you look at the code of HttpWebRequest with Reflector or dotPeek you'll see that exception is thrown intentionally. So probably you would like to re-implement the same code, or use another classes for sending requests.

– Alexey F Nov 11 at 15:37.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions