1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
//partie deconnexion
HttpWebRequest oWRequest = (HttpWebRequest)HttpWebRequest.Create("http://192.168.1.1/apply.cgi");
oWRequest.Method = "POST";
oWRequest.ContentType = "application/x-www-form-urlencoded";
oWRequest.Credentials = new NetworkCredential("admin", "admin");
ASCIIEncoding encoding = new ASCIIEncoding();
encoding = new ASCIIEncoding();
byte[] loginDataBytes = encoding.GetBytes("submit_button=submit_button=Status_Router&submit_type=disconnect&change_action=gozila_cgi&wan_proto=dhcp");
oWRequest.ContentLength = loginDataBytes.Length;
Stream stream = oWRequest.GetRequestStream();
stream.Write(loginDataBytes, 0, loginDataBytes.Length);
stream.Close();
HttpWebResponse oWResponse = (HttpWebResponse)oWRequest.GetResponse();
//partie connexion
oWRequest = (HttpWebRequest)HttpWebRequest.Create("http://192.168.1.1/apply.cgi");
oWRequest.Method = "POST";
oWRequest.ContentType = "application/x-www-form-urlencoded";
oWRequest.Credentials = new NetworkCredential("admin", "admin");
ASCIIEncoding encoding = new ASCIIEncoding();
encoding = new ASCIIEncoding();
loginDataBytes = encoding.GetBytes("submit_button=Status_Router&submit_type=connect&change_action=gozila_cgi&wan_proto=dhcp");
oWRequest.ContentLength = loginDataBytes.Length;
stream = oWRequest.GetRequestStream();
stream.Write(loginDataBytes, 0, loginDataBytes.Length);
stream.Close();
Exception ici -> HttpWebResponse oWResponse = (HttpWebResponse)oWRequest.GetResponse(); |
Partager