Whats the best way to return XML data from an MVC controller? I am using Visual Studio 2015. I have tried this but it didn't work:
return new XmlResult(s);
return this.Content(xmlString, "text/xml", System.Text.Encoding.UTF8);
You could use
public ActionResult Index()
{
ViewBag.Title = "Home Page";
string xmlData="<xml ?>.....";
return Content(xmlData, "text/xml", System.Text.Encoding.UTF8);
}
to return a built XML string from an action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With