C # Use the HttpHelper universal framework to restart the router,
First, declare that not all routers can restart the vro through the following code.
The following code tests the router is (TP-LINK TD-W89841N reinforced ). Write code based on your vro.
1 using CsharpHttpHelper; // reference the HttpHelper class library 2 using System; 3 using System. text; 4 5 namespace ConsoleApplication1 6 {7 class Program 8 {9 static void Main (string [] args) 10 {11 HttpHelper http = new HttpHelper (); 12 HttpItem item = new HttpItem () 13 {14 Referer =" http://192.168.1.1/ ", 15 // This cannot be less than 16 URLs =" http://192.168.1.1/ Cgi? 7 ", 17 Method =" Post ", 18 Postdata =" [ACT_REBOOT #, #,] \ r \ n ", 19 // the \ r \ n at the end cannot be less than 20 cookies = "Authorization = Basic XXXXXXXXXXXXXXX =", 21 // Authorization = Basic Base64 encrypt your password 22 23 }; 24 HttpResult result = http. getHtml (item); 25 if (result. statusCode = System. net. httpStatusCode. OK) 26 {27 if (result. html = "[error] 0") 28 {29 Console. writeLine ("vro restarted successfully! "); 30} 31 else32 {33 Console. WriteLine (result. Html); 34} 35} 36 Console. ReadKey (); 37} 38} 39}
HttpHelper universal framework Web site: http://httphelper.sufeinet.com/