Return XML from a controller's action in as an ActionResult? Ask Question

Return XML from a controller's action in as an ActionResult? Ask Question

What is the best way to return XML from a controller's action in ASP.NET MVC? There is a nice way to return JSON, but not for XML. Do I really need to route the XML through a View, or should I do the not-best-practice way of Response.Write-ing it?

ベストアンサー1

return this.Content(xmlString, "text/xml");

おすすめ記事