从一个WPF / XBAP应用检测网络连接? [英] Detect network connectivity from a WPF/XBAP Application?

查看:118
本文介绍了从一个WPF / XBAP应用检测网络连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法来确定一个XBAP(WPF承载于浏览器)应用程序的网络连接?如果不是,如何将传统的Windows客户端写在C#和.NET确定它是否有连接?

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?

基本上用例是连接到通过WiFi企业内部网的移动笔记本电脑上运行的XBAP程序。这种笔记本电脑将不会有互联网连接。 WiFi连接可能或可能不存在,这取决于用户所在处的时间。

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.

推荐答案

GateWayIPAddressInformation应该工作:<一href="http://msdn.microsoft.com/en-us/library/system.net.networkinformation.gatewayipaddressinformation" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.net.networkinformation.gatewayipaddressinformation(loband).aspx

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

如果你的网关IP地址,并且您可以ping(的http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping(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.

这篇关于从一个WPF / XBAP应用检测网络连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆