What is your prefered way to return XML from an ActionMethod in Asp.net MVC?
Posted
by serbrech
on Stack Overflow
See other posts from Stack Overflow
or by serbrech
Published on 2010-04-07T13:43:24Z
Indexed on
2010/04/07
13:53 UTC
Read the original article
Hit count: 205
asp.net-mvc
|Xml
I am displaying charts that load the data asynchronously because the searches are the work to fetch the data is quite heavy. The data has to be return as XML to make the chart library happy.
My ActionMethods return a ContentResult with the type set as text/xml. I build my Xml using Linq to XML and call ToString. This works fine but it's not ideal to test.
I have another idea to achieve this which would be to return a view that builds my XML using the XSLT View engine.
I am curious and I always try to do the things "the right way". So how are you guys handling such scenarios?
Do you implement a different ViewEngine (like xslt) to build your XML or do you Build your XML inside your controller (Or the service that serves your controller)?
© Stack Overflow or respective owner