View Sidebar
How to check for a network connection in .NET 2.0 (C# or VB)

How to check for a network connection in .NET 2.0 (C# or VB)

January 18, 2006 1:15 am17 comments

To check for a network connection in .NET 2.0 use this:


To monitor a change in IP address or a change in network availability, use the events from the NetworkChange class:




  • Shinichi

    Thanks !

    I use it to get all Network Connection on system !

  • Thanks a lot man,
    I will use your tip in my software.

    Good Tips From Good Men …

  • Great info!
    I’ll use this before pinging my webservices :D

  • Narasimha Murthy


    How can I check web services availability.(.net 2.0 C# or

  • 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 :-)

  • Great Information,
    Thanks a lot and you are good in knowledge sharing

  • tejaswini

    Thanks for sharing this information.
    It helped to do one of my task.
    God bless u :)

  • 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.

  • Dilip

    It helped me………

  • Steve R

    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.

  • samir

    how to make service to check the network connection is now is running

  • Petroclus

    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.

  • darshan

    Thanks it helped a lot.
    Please keep posting such stuff.

  • kamran

    thank you . it works :D

  • Thnx for this article…. But how can i check internet speed in c#.

  • thank it works