I'm facing a problem where I need to verify that my windows forms application has access to the internet before it can do anything. Currently, the only way I can think of is by creating a HttpWebRequest and point it to the specified URL I wish to connect to later on, and if that throws an error, I know I don't have an internet connection. Is this the best method for detecting an internet connection, or is there some sort of routine that I need to follow that is more tuned for performance?

Thanks for your help!

Matt Hawley, MCAD .NET
http://www.eworldui.net

RE: Detecting Internet Connection by anonymous

anonymous
Mon Apr 26 11:01:10 CDT 2004

I believe this is the method that the vast majority of applications use to identify whether they are online, regardless of whether they run on the .NET Framework or not

It is also the method used to verify that an existing connection is still "connected"

~~K

Re: Detecting Internet Connection by Elp

Elp
Mon Apr 26 11:30:06 CDT 2004


"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF4Klw5KEHA.1956@TK2MSFTNGP10.phx.gbl...
> I'm facing a problem where I need to verify that my windows forms
application has access to the internet before it can do anything. Currently,
the only way I can think of is by creating a HttpWebRequest and point it to
the specified URL I wish to connect to later on, and if that throws an
error, I know I don't have an internet connection. Is this the best method
for detecting an internet connection, or is there some sort of routine that
I need to follow that is more tuned for performance?

This seems to be the only reliable method to check for an internet
connection. Google will give you other solutions but they generaly rely on
checking if there's a network device configured which doesn't ensure you
that the computer has actually access to the internet. And even if it has
access to the internet, it may be behind a proxy server that restricts this
access to some sites or particular protocols. So the only way to know for
sure if a computer can access your particular site is to try...