.net - Problems capturing HTTP response -


i have code makes http request:

                //successful request                 var requestinbytes = encoding.getbytes(urlwithparameters.tostring());                  httpwebrequest req = (httpwebrequest)webrequest.create(urlwithparameters.tostring());                 req.method = "post";                 req.contentlength = requestinbytes.length;                 req.contenttype = "application/x-www-form-urlencoded";                  stream newstream = req.getrequeststream();                  // send data.                 newstream.write(requestinbytes, 0, requestinbytes.length);                 newstream.close(); 

however, i'm having trouble capturing response. right now, i'm trying this:

            //no response?             system.io.streamreader st = new streamreader(((httpwebresponse)req.getresponse()).getresponsestream());             var response = st.readline(); 

but coming blank response?

try:

httpwebresponse response = req.getresponse(); 

you can check various properties of response.

or

try:

var response= req.readtoend(); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -