469,299 Members | 2,073 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

Web Connections

Does .net Framework 2.0 have anything new to help us detect if a user has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis
Dec 1 '05 #1
6 4143
Hi,
AFAIK there is no way to know it, you could use some workaround like
1:- Try to establish a connection to a know website (useless if a mandatory
proxy is in place)
2- Try to make a ping to some remote computer (useless if a firewall is
present)
3- Try to resolve a name ( this IMO is the more sure way )
Other than that I cannot think of another way.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dennis C. Drumm" <dc******@community.nospam> wrote in message
news:Oc**************@TK2MSFTNGP09.phx.gbl...
Does .net Framework 2.0 have anything new to help us detect if a user has
an active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 1 '05 #2
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected, uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 1 '05 #3
Hi Dennis,
Welcome to MSDN Newsgroup!

From my experience, there is no notified message which will be sent when
user has an active internet connection. If we want to get current internet
information, I suggest you to call some APIs (for example:
InternetCheckConnection, InternetGetConnectedStateEx ) in WinInet using
P/Invoke mechanism.

I hope the above information is helpful for you. If you have any questions
or concerns, please let me know. Thanks again and have a nice day!

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Dec 2 '05 #4
One word of warning; InternetGetConnectedState is easily confused and can
report an internet connection when there isn't one. It's a good first check,
but you need to do more.

In my old VB6 apps, I use InternetGetConnectedState to make the first check
and, if it reports that there is an internet connection, I attempt to
connect to a known FTP site (our company web site, actually) and only if
that connection can be established do I take it as proof that there is an
internet connection.

Steve
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:60**********************************@microsof t.com...
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected,
uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user has
an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis

Dec 2 '05 #5
It appears that a new class for .net framework 2.0 is PingReply and by using
the Status property one can determine if some known web site is accessible.

This would seem to do the trick and I think would avoid the annoying side
affect of causing someone's computer that only has a dialup connection to
try to connect without being asked to.

What do you all think?

Dennis
"Steve Barnett" <no****@nodomain.com> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
One word of warning; InternetGetConnectedState is easily confused and can
report an internet connection when there isn't one. It's a good first
check, but you need to do more.

In my old VB6 apps, I use InternetGetConnectedState to make the first
check and, if it reports that there is an internet connection, I attempt
to connect to a known FTP site (our company web site, actually) and only
if that connection can be established do I take it as proof that there is
an internet connection.

Steve
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:60**********************************@microsof t.com...
Nothing built in other than attempting a download via HttpWebRequest.
However, with an API, its easy:

[DllImport(@"C:\Windows\System32\wininet.dll")]
// this method will check the internet connection state
public static extern bool InternetGetConnectedState(ref uint connected,
uint
reserved);

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Dennis C. Drumm" wrote:
Does .net Framework 2.0 have anything new to help us detect if a user
has an
active internet connection and to send a notice when a connection is
established or dropped?

Thanks,

Dennis


Dec 2 '05 #6
Hi Dennis,
Nice to see you again!
PingReply could help us get the status of an attempt to send an Internet
Control Message Protocol (ICMP) echo request and receive the corresponding
ICMP echo reply message. We could determine whether or not some web site is
accessible depending on this status.
Thanks for your sharing knowledge. It will benefit others in the newsgroup
facing this issue.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Dec 5 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randell D. | last post: by
3 posts views Thread by Mudge | last post: by
4 posts views Thread by Angelos | last post: by
1 post views Thread by C Sharp beginner | last post: by
2 posts views Thread by Bob | last post: by
17 posts views Thread by Peter Proost | last post: by
4 posts views Thread by elyob | last post: by
1 post views Thread by marcfischman | last post: by
13 posts views Thread by PRP | last post: by
5 posts views Thread by Usman Jamil | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.