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?
You can't return a string from a method which returns an ActionResult, so in this case you return Content("") as swilliams explained. If you only ever need to return a string, then you would have the method return a string, as Phil explained.
An action result is what a controller action returns in response to a browser request. The ASP.NET MVC framework supports several types of action results including: ViewResult - Represents HTML and markup. EmptyResult - Represents no result.
You could use return this.Content(xmlString, "text/xml");
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