c# - Find out results of httpwebrequest POST -


please refer below code. how can test/debug, whether below code worked correctly or not. runs , there no compilation/runtime errors.

the end result of below code set 1 of controls in page, hold post data below code. haven't come far yet.

   protected override void oninit(eventargs e) {      asciiencoding encoding = new asciiencoding();     string postdata = "http://s.com/is/image/scom/2peel";     byte[] data = encoding.getbytes(postdata);      // prepare web request...     httpwebrequest myrequest = (httpwebrequest)webrequest.create("http://m.com/confirm.aspx?id=175");     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();  } 

update 1: tried find out response using below code, page doesn't load @ all.

httpwebresponse response = (httpwebresponse)myrequest.getresponse();  console.writeline("content length {0}", response.contentlength); console.writeline("content type {0}", response.contenttype); 

use getresponse method of httpwebrequest object (which named "myrequest").


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -