c# - Migrate Post action to web forms -
i have action on mvc application , need same thing in application uses web forms. i'm sorry if such stupid thing i'm not expert on web forms.
this action:
[httppost] public actionresult login(string username) { }
how do httppost in web form?
update
i discovered if put (page.request["login"]) in code i'm able retrieve post parameters.
i believe want use httpwebpost classclass.
something
private void onpostinfoclick(object sender, system.eventargs e) { string strid = userid_textbox.text; string strname = name_textbox.text; asciiencoding encoding=new asciiencoding(); string postdata="userid="+strid; postdata += ("&username="+strname); byte[] data = encoding.getbytes(postdata); // prepare web request... httpwebrequest myrequest = (httpwebrequest)webrequest.create("http://localhost/default.aspx"); myrequest.method = "post"; myrequest.contenttype="application/x-www-form-urlencoded"; myrequest.contentlength = data.length; stream newstream=myrequest.getrequeststream(); // send data. newstream.write(data,0,data.length); newstream.close(); }
Comments
Post a Comment