Silverlight 3 detecting network connectivity


Most silverlight applications depend on some sort of network connectivity. They update data using a webservice, sockets or have streaming video. With the new detach capabilities of Silverlight 3 it will be possible to run the application locally when the user is offline.
When enabeling your application to run locally, you should provide a different user experience.

You can detect the network connectivity by calling the NetworkInterface.GetIsNetworkAvailable(); method. It will return true or false.


Do you want to be notified when any network connectivity changes occur? Subscribe to the following event:
NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(NetworkChange_NetworkAddressChanged);

Network available, but no connection to the internet?
If the NetworkInterface tells you the network is available, it doesn't always mean you're connected to the internet. It only means the local PC has a valid IP address.
It is recommended to ping a webservice or download a simple small file from the webserver to verify you have access to the internet.


Jnn 28-06-2010
But.. how do you catch the exception: "The remote server returned an error: NotFound" when load a web service?

New Comment

E-mail (not published)
Enter the code shown: