Internet Accessible?

M

Michael Nemtsev

P

perspolis

Hi all
How can I find that user is connected to internet or not?

thanks in advance
 
P

Peter Thornqvist

Is there an equivalent to InternetCheckConnection in .Net? If not, why not
interop it?

Here's another alternative:

using System.Net;

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(@"http://www.microsoft.com");


An exception indicates that the site isn't reachable thus probably there is
no internet connection (ms site could be down as well, but that is not as
probable).
 
G

Guest

This is the check for network connectivity (in .NET 2.0):

System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();

This will tell you only if you are connected to something (network, dialup,
wireless etc), not whether the internet is contactable. The best bet is to
try and do what you want to do and handle any exceptions, or try and open
something like google for microsoft to check for connectivity.

HTH

Ciaran O'Donnell
 
G

Guest

You can also handle events with network availability at
System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged
and you can ping webserver to check for connectivity too.
System.Net.NetworkInformation.Ping

HTH

Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top