views:

116

answers:

3

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 connect to our main office

What would I need to detect wifi connectivity?

+4  A: 

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.

casperOne
so you are saying this needs to be a winforms app? (which is fine). I just don't know how to develop something that can detect wifi signals
MJH
@MJH: see http://stackoverflow.com/questions/496568/how-do-i-get-the-available-wifi-aps-and-their-signal-strength-in-net .
cHao
A: 

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.

MusiGenesis
@MusiGenesis: why would you use ASP.NET on the server? Why not WCF?
John Saunders
@John Saunders: because the asker mentioned ASP.NET and WinForms. I personally use ASP.NET over WCF because I usually support both PC and Windows Mobile clients, and WCF on WinMo is a real pain.
MusiGenesis
WCF with `basicHttpBinding` in the service doesn't work well with Windows Mobile? I don't think so.
John Saunders
@John: I didn't say WCF doesn't work well with Windows Mobile - I said that it's a pain to implement it, which it is, especially when compared with how easy it is to consume ASMX web services from Windows Mobile.
MusiGenesis
@Music: write the service in WCF; use `basicHttpBinding`; consume it with "Add Web Reference"; done.
John Saunders
@John: it's not that simple. See: http://wcfguidanceformobile.codeplex.com/ It also requires .NET CF 3.5, which my clients have not approved yet.
MusiGenesis
+3  A: 

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.

sarme