开发者

Detect wifi connectivity in c#

I am working on an asp.net (or winforms) app that is supposed to detect wifi connectivity and strength. The intention is to provide the field agents with an indicator that they can c开发者_Python百科onnect to our main office

What would I need to detect wifi connectivity?


You can't do it in ASP.NET. ASP.NET is a server-side technology which renders client-side browsable code.

In order to do this, you would have to develop something that is embedded in the page (ActiveX, Java, Flash, Silverlight) and even then, you would have to have the appropriate security permissions from the user to access the APIs necessary to access the wifi antenna.


Take a look at WlanEnumInterfaces in the wlanapi.dll. You will have to pinvoke it from C#. There is a managed wrapper for it on Codeplex (http://managedwifi.codeplex.com), but I can't vouch for it as I've never used it personally.

You can still do with with ASP.Net if you don't mind writing an ActiveX object and your clients don't mind running it from your web site.


You can actually do this pretty simply using both WinForms and ASP.NET. On your server, you create a web service with a single method that returns true. For your clients, you write a winforms application (something that sits in the tray would be ideal) that polls the web service every 5 or 10 seconds (or whatever interval you want) with a timeout of a few seconds less. If the web service call returns without throwing a timeout exception, then you know you're connected. If it times out, you know you're not connected (and you could, for example, show a little light that's green when connected and red when not connected).

Note that you would not actually be measuring the WIFI availability (or its signal strength) in any way, but this is probably not something your field agents really care about anyway. They probably just want to know if they can connect or not.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜