1

I'm trying to catch an exception while doing:

myStreamRequest = GetRequestStream()

The problem is that I get the same error when my pc doesn't have a correct network connection (it is unplugged) and when the requested URL is not correct. The exception is WebException and the status: NameResolutionFailure, and I need to make a difference between those two errors. I've been trying to catch a possible innerException, but it is not thrown in this case.

What should I do?

John Conde
  • 217,595
  • 99
  • 455
  • 496
Doubting
  • 38
  • 4

1 Answers1

1

You can check for the existance of a network, before you make a request.

System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
Community
  • 1
  • 1
NaveenBhat
  • 3,248
  • 4
  • 35
  • 48
  • Thank you so much!!!!it works fine, i didn't think I could do something like this, I was trying to do a very difficult checking but this is so easy and so helpful!!!!Thank you! – Doubting Aug 16 '12 at 15:31
  • @Doubting - You are welcome! Dont forget to [mark the answer as accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work). Also, you can upvote if you found the answer helpfull. – NaveenBhat Aug 16 '12 at 15:35