c# - How to send xml through an HTTP request, and receive it using ASP.NET MVC? -


i trying send xml string through http request, , receive on other end. on receiving end, getting xml null. can tell me why is?

send:

    var url = "http://website.com";     var postdata = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?><xml>...</xml>";     byte[] bytes = system.text.encoding.ascii.getbytes(postdata);      var req = (httpwebrequest)webrequest.create(url);      req.contenttype = "text/xml";     req.method = "post";     req.contentlength = bytes.length;      using (stream os = req.getrequeststream())     {         os.write(bytes, 0, bytes.length);     }      string response = "";      using (system.net.webresponse resp = req.getresponse())     {         using (streamreader sr = new streamreader(resp.getresponsestream()))         {             response = sr.readtoend().trim();         }      } 

receive:

[httppost] [validateinput(false)] public actionresult index(string xml) {     //xml null     ...     return view(model); } 

i able working so:

[httppost] [validateinput(false)] public actionresult index() {     string xml = "";     if(request.inputstream != null){         streamreader stream = new streamreader(request.inputstream);         string x = stream.readtoend();         xml = httputility.urldecode(x);     }     ...     return view(model); } 

however, still curious why taking xml parameter not work.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -