I want to restart the router by programatically using c# like to create exe to restart the router
How to do it please give me some idea or any code which will help me
I have used some following codes:
WebRequest routerConnectionObj = WebRequest.Create(routerURL);
routerConnectionObj.PreAuthenticate = true;
// Add the Credentials for login
routerConnectionObj.Credentials = new NetworkCredential("userName", password);
// Type of method Get/ Post
routerConnectionObj.Method = "Post";
string postContent = "connect=+Renew+&refreshScrn=yes";
string postContent = "connect=+Renew+&refreshScrn=yes";
// Content type may be text or encoded
routerConnectionObj.ContentType = "application/x-www-form-urlencoded";
routerConnectionObj.ContentLength = postContent.Length;
// Get the requested stream and add postContent data
StreamWriter myWriter = new StreamWriter(routerConnectionObj.GetRequestStream());
myWriter.Write(postContent);
myWriter.Close();
//get the response from server
HttpWebResponse responseObj = (HttpWebResponse)routerConnectionObj.GetResponse();
HttpStatusCode statusCode = responseObj.StatusCode;
Hemant KumarPosted Mar 6, 2012, 2:08 AM
There aren't any APIs out there to do this, but you can write something to make HTTP requests to the router to simulate the webUI being used.
I'm guessing most consumer routers are probably pretty simple to talk to. Authentication is probably nothing more than basic realm.
Hemant KumarPosted Mar 6, 2012, 2:08 AM
There aren't any APIs out there to do this, but you can write something to make HTTP requests to the router to simulate the webUI being used.
I'm guessing most consumer routers are probably pretty simple to talk to. Authentication is probably nothing more than basic realm.