How to pass XML as POST to an ActionResult in ASP MVC .NET

后端 未结 7 849
[愿得一人]
[愿得一人] 2020-12-15 10:05

I am trying to provide a simple RESTful API to my ASP MVC project. I will not have control of the clients of this API, they will be passing an XML via a POST method that wi

7条回答
  •  旧时难觅i
    2020-12-15 10:35

    Why can they not pass the xml as a string in the form post?

    Example:

    public ActionResult SendMeXml(string xml)
    {
      //Parse into a XDocument or something else if you want, and return whatever you want.
      XDocument xmlDocument = XDocument.Parse(xml);
    
      return View();
    }
    

    You could create a form post and send it in a single form field.

提交回复
热议问题