My wireless router doesn't get on well with my wife's Samsung NC10 netbook. I've tried updating the netbook's wireless driver, the router's firmware (no new version available) and changing the channel but still no success. It's odd, because the router works fine with my other wireless devices but the only way to solve the problem is to restart the router, not the netbook.
At present, this is a real pain as the router is hidden away in a cupboard in the back bedroom. So I came up with something of a roundabout solution, if it's fair to call it a solution at all.
The idea was to use one of my servers to host a public endpoint in IIS that would talk to the router over a wired link and ask it to reset. I suspected I'd be in for a fair bit of screenscraping to interact with the router's web-based UI but it turned out to be scarily simple.
I used fiddler
to trace the HTTP interaction a user's browser has when resetting the router so I could recreate this using the System.Net.WebClient in ASP.NET. The right choice for an ASP.NET 'page' that doesn't need any controls is a handler. And this is all I needed to get it working.
public class MyResetRouterHandler : IHttpHandler
public void ProcessRequest(HttpContext context)
WebClient client = new WebClient();
using (Stream s = client.OpenRead("http://22.214.171.124/rebootinfo.cgi"))
using (StreamReader sr = new StreamReader(s))
public bool IsReusable
The idea being that my wife can then request the page https://my.public.server.url/ResetRouterApplication/MyResetRouterHandler.ashx from her phone
and the router will reset. She'll then be fine to surf on the netbook within about 30 seconds.
Of course, you need to be very cogniscent of security when doing this as you're effectively creating a route through you NAT and firewall to your routers UI - I even opted to go for SSL.
However, this does open up some coding-for-fun at home opportunities. My next 'job' is to create a UI that gets the last DCHP client list from the router and gives me the option of sending the 'magic packet' to the appropriate IP and MAC address to Wake On Lan
(WoL) any machine. This is particularly useful if I want to remote into a machine and it's off or sleeping.
20 Jun 2009
» Next Post:
Using Windows Search in your applications
« Previous Post:
Merging XPS Documents
Comments are closed for this post.
20 Jun 2009
Reminds me of one of the first C# programs I ever wrote: a small application to restart my cable modem. Actually, it had to change the router setup, reboot the modem, and then change the router back (all via HTTP). :)
Then I changed it into a service that checked Internet connectivity periodically and performed the restart automatically when it went down.
It makes you wonder: how do non-programmers live? :)