How to check for a network connection in .NET 2.0 (C# or VB)
January 18th, 2006To check for a network connection in .NET 2.0 use this:
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
To monitor a change in IP address or a change in network availability, use the events from the NetworkChange class:
System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged
System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged


June 6th, 2008 at 7:27 am
Thanks !
I use it to get all Network Connection on system !
September 23rd, 2008 at 12:01 am
Thanks a lot man, I will use your tip in my software.
Good Tips From Good Men …
October 21st, 2008 at 9:19 pm
Great info! I’ll use this before pinging my webservices :D
March 17th, 2009 at 2:41 am
Hi,
How can I check web services availability.(.net 2.0 C# or vb.net)?
November 9th, 2009 at 8:17 pm
There’s a MIX video on how to do this in Silverlight. The same APIs work in .NET as well. One of the key bits is that you’re only connected to the internet if you’ve made a connection to your server and have verified the response — otherwise you might just connected to a local web page asking you for $9.95 to connect for a day :-)
January 12th, 2010 at 6:13 am
Great Information, Thanks a lot and you are good in knowledge sharing
February 24th, 2010 at 10:03 am
Thanks for sharing this information. It helped to do one of my task. God bless u :)
February 25th, 2010 at 4:49 am
I’m facing a bit problem using ‘NetworkAvailabilityChanged’. If I’m connected through multiple interfaces at a time then I didn’t get ‘NetworkAvailabilityChanged’ event fired. But if I’m using single connection then this event fires. Could you please suggest a solution.
February 25th, 2010 at 6:35 am
Thanks, It helped me………
April 28th, 2010 at 4:35 am
Hi Zeus, if you have multiple network connections you’ll only receive the NetworkAvailabilityChanged event when all connections are disconnected and when 1 connection is re-established. The line below is taken from the MSDN documentation for this event.
The NetworkChange class raises NetworkAvailabilityChanged events when the availability of the network changes. The network is available when at least one network interface is marked “up” and is not a tunnel or loopback interface.
May 8th, 2010 at 8:49 am
how to make service to check the network connection is now is running
July 27th, 2010 at 7:15 am
The NetworkAvailabilityChanged event doesn’t appear to get raised when a ‘Dial-Up Connection’ is disconnected. (It does when the dial-up connection is made though). It may be model/driver specific – I’ve only tried it on a ZTE GSM modem.