How to return an XML string as an action result in MVC

Toran Billups picture Toran Billups · May 18, 2009 · Viewed 51.2k times · Source

Possible Duplicate:
What is the best way to return XML from a controller's action in ASP.NET MVC?

I'm able to return JSON and partial views (html) as a valid ActionResult, but how would one return an XML string?

Answer

John Downey picture John Downey · May 18, 2009

You could use return this.Content(xmlString, "text/xml"); to return a built XML string from an action.