Tuesday 15 September 2015

c# - How make a post to URL and get the response -



c# - How make a post to URL and get the response -

i seek post xml file url , response back. have code post. not sure how check if posting correctly , how response.

webrequest req = null; webresponse rsp = null; // seek // { string filename = @"c:\applicantapproved.xml"; string uri = "http://stage.test.com/partners/wp/ajax/consumexml.php"; req = webrequest.create(uri); req.method = "post"; // post method req.contenttype = "text/xml; encoding='utf-8'"; // wrap request stream text-based author streamwriter author = new streamwriter(req.getrequeststream()); // write xml text stream writer.writeline(this.gettextfromxmlfile(filename)); writer.close(); // send info webserver rsp = req.getresponse();

i think should have response in rsp not seeing usufull on it.

try req.contenttype = "application/xml";

c# asp.net post http-post

No comments:

Post a Comment