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

What would I need to detect wifi connectivity?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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.

Method 3

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x