自动路由器重启 [英] Automatic router rebooter

查看:109
本文介绍了自动路由器重启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我想制作一个程序,如果它与Internet断开连接,则会自动重新启动路由器.

现在,它导航到正确的站点,但是有一个名为Reboot的按钮.

属性:

输入type ="submit" class ="buttonText" value =重新启动" style ="cursor:hand"

我不能做的是通过webrequest按下该按钮.我已经做过的事情:

Hello!

I would like to make a program which automatically reboots the router if it disconenct from the internet.

Now, it navigates to the right site, but there''s a button called Reboot.

properties:

input type="submit" class="buttonText" value="Reboot" style="cursor:hand"

What I can''t do is pressing that button by webrequest. What I''ve done already:

WebRequest myReq = WebRequest.Create("http://192.168.1.254/GBreboot.htm");
            string username = "name";
            string password = "pw";
            string usernamePassword = username + ":" + password;
            CredentialCache mycache = new CredentialCache();
            mycache.Add(new Uri("http://192.168.1.254/GBreboot.htm"), "Basic", new NetworkCredential(username, password));
            myReq.Credentials = mycache;
            myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));

            WebResponse wr = myReq.GetResponse();
            Stream receiveStream = wr.GetResponseStream();
            WebResponse response = (WebResponse)myReq.GetResponse();
            StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
            string resphtml = reader.ReadToEnd();





Any ideas?

推荐答案

这可能有帮助,但不能保证:

http://social.msdn.microsoft.com/论坛/en-US/winforms/thread/0d33e2f4-f9f7-4174-8dc3-6ee2fb8130e4 [
This might help, but no guarantees:

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/0d33e2f4-f9f7-4174-8dc3-6ee2fb8130e4[^]


当您实际按下按钮时,您可以尝试找出浏览器正在发送的请求.使用类似 Fiddler2 [
You can try to find out what request is being sent by the browser when you actually press the button yourself. Use a tool like Fiddler2[^] for that.
Then in the first step you do what you did in your existing code to setup an authenticated session. The second step would be to send a request like the one you traced with Fiddler but useing the session information from the first step (session cookies or whatever).

Hope this helps!

Regards,

Manfred


这篇关于自动路由器重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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