c# - How to accept xml file in via http post method and parse request headers.? -


i sending xml file web broser rest client. need accept xml file in asp.net web api http post method.

how xml file content , file name , headers content asp.net web api http post method.?

i referred few msdn links such http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2 , did not tutorial

somehow wrote code

httprequestmessage request = this.request; var task = this.request.content.readasstreamasync();  task.wait(); stream requeststream = task.result;  string inp = request.content.readasstringasync().result; string result = await request.content.readasstringasync();  try {     stream filestream = file.create(@"c:\\test\\1.xml");     requeststream.copyto(filestream);     filestream.close();     requeststream.close(); } catch (ioexception) {     throw new httpresponseexception("a generic error occured. please try again later.", httpstatuscode.internalservererror); } 

through above code don't full xml content.

i new asp.net web api , .net framework. please provide procedure implement , code.

if posting xml file via file upload, this link @ www.asp.net should help. otherwise, if posting string shouldn't need special other supply string parameter in controller method receive xml string (in case web api automagically mapping you).


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -