Detect network connectivity from a WPF/XBAP Application?

Someone asked on Stack Overflow:

Is there any way to determine if an XBAP (WPF hosted in a browser) application has network connectivity? If not, how would a traditional windows client written in C# and .NET determine if it has connectivity?

Basically the use case is an XBAP application running on a mobile laptop connected to an intranet via WiFi. The laptop will not have a connection to the Internet. The WiFi connection may or may not be there depending upon where the user is at the time.

I posted the following answer, which was chosen as the accepted answer and received 4 upvotes:

GateWayIPAddressInformation should work: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.gatewayipaddressinformation(loband).aspx

If you get the gateway IP address, and you can Ping (http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping(loband).aspx) it you are probably connected.


Originally posted on Stack Overflow — 4 upvotes (accepted answer). Licensed under CC BY-SA.

signed letter b

Dad. Geek. Gamer. Software developer. Cloud user. Old Car enthusiast.  Blogger.


Top Posts


profile for Nate on Stack Exchange, a network of free, community-driven Q&A sites
a proud member of the blue team of 512KB club
Thoughts, opinions, and ideas shared here are my own. © 2026 Nate Bross.