473,231 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Detecting Internet Connection

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
Jul 21 '05 #1
6 2526
Elp

"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF**************@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...
Jul 21 '05 #2
Elp

"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF**************@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...
Jul 21 '05 #3
Good explanation. Thanks!

Matt Hawley, MCAD .NET
http://www.eworldui.net
"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF**************@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...

Jul 21 '05 #4
Good explanation. Thanks!

Matt Hawley, MCAD .NET
http://www.eworldui.net
"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF**************@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...

Jul 21 '05 #5
Yes ... Except that it doesn't always work.

Our WinForms app is heavily dependent on the Internet and our biggest
support problem is people with perfectly valid Internet connections that the
app (using the method below) fails to detect. It appears that .Net has a
great deal of trouble with some proxies that require login (including the MS
one) and, it seems, with VPN connections. We have not been able to resolve
this and it's increasingly frustrating as it's not anything we've been to
repro here although several customers, including IT managers and developers,
have noted this problem. It's very real and very, very frustrating. In all
cases, the customer using IE can access the URL just fine; it only fails
when we do the WebRequest.

Any suggestions would be appreciated.

The code we use is something like (simplified):

Try

wr = CType(WebRequest.Create(UseURL), HttpWebRequest)

Resp = CType(wr.GetResponse(), HttpWebResponse)

Catch we As WebException

'Connection failed

End try

One thing -- we do lock the ProtocolVersion to 1.0 for backwards compat with
some systems. Can that be an issue with some proxies? Is there something
we are specifically supposed to be to ensure that we login to the proxy?

Thanks, Steve

"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Good explanation. Thanks!

Matt Hawley, MCAD .NET
http://www.eworldui.net
"Matt Hawley" <mhawley@!n!o!s!p!a!m!.integrityts.com> wrote in message
news:eF**************@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...

Jul 21 '05 #6
Elp
Hi Steve,

"Steve Podradchik" <St*************@hotmail.com> wrote in message
news:uK**************@TK2MSFTNGP09.phx.gbl...
Yes ... Except that it doesn't always work.

Our WinForms app is heavily dependent on the Internet and our biggest
support problem is people with perfectly valid Internet connections that the app (using the method below) fails to detect. It appears that .Net has a
great deal of trouble with some proxies that require login (including the MS one) and, it seems, with VPN connections.


Have a look at the WebProxy class. In theory, it should allow you to specify
the Web proxy server to be used and a login/password to use for the proxy
server login. I've never had to occasion to test it in a real life situation
but it will maybe solve at least some of your problems
Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Peter Flynn | last post by:
I'm having trouble finding example code to detect the presence of an Internet connection. It doesn't seem to be a very frequently asked question, as all I need is the answer yes or no (is the user...
8
by: Matt Hawley | last post by:
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...
3
by: Graeme Hinchliffe | last post by:
Hiya I have now managed to get my code to function correctly for a none present db, and one that is shutdown whilst it is being used. In both cases my code functions and happily recovers on the...
0
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m facing a big problem... How can i detect that either the internet connection id dialup or is on LAN or is their both connection exists...... and what is the connection speed. And is...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.