c# - WebRequest to post data in Login page -
i read questions similar titles , test codes problem not solved. problem: need program in c# post dates modem login page. modem wimax bm632. address of login page htp://192.168.1.1/ , action of form there in http://192.168.1.1/ http://192.168.1.1/index/login.cgi (form action). want when login success go http://192.168.1.1/html/wimax/security.asp , page source. login page : http://chamalz.persiangig.com/image/1.jpg
i write code:
webrequest request = webrequest.create("http://192.168.1.1/index/login.cgi"); request.method = "post"; string postdata = "username=admin&password=ywrtaw4%3d"; byte[] bytearray = encoding.utf8.getbytes (postdata); request.contentlength = bytearray.length; stream datastream = request.getrequeststream (); datastream.write (bytearray, 0, bytearray.length); datastream.close (); webresponse response = request.getresponse (); textbox1.text=(((httpwebresponse)response).statusd escription); datastream = response.getresponsestream (); streamreader reader = new streamreader (datastream); string responsefromserver = reader.readtoend (); textbox1.text= (responsefromserver); reader.close (); datastream.close (); response.close ();
this code has no error have problem : when post user name , password correct or incorrect received 1 response in textbox1.text response : http://chamalz.persiangig.com/image/2.jpg
please me.
first need know data sent login page via post method. achieving must login manualy , capture posted data login page possible using http capture software httpdebugger after find correct post data , httpheader can put data on code , try login programaticaly
Comments
Post a Comment