Quantcast
Channel: Return XML from a controller's action in as an ActionResult? - Stack Overflow
Browsing latest articles
Browse All 12 View Live

Answer by Hamid Jolany for Return XML from a controller's action in as an...

use one of these methods public ContentResult GetXml() { string xmlString = "your xml data"; return Content(xmlString, "text/xml"); }or public string GetXml() { string xmlString = "your xml data";...

View Article



Answer by Nelson Lopez Centeno for Return XML from a controller's action in...

A small variation of the answer from Drew Noakes that use the method Save() of XDocument.public sealed class XmlActionResult : ActionResult{ private readonly XDocument _document; public string MimeType...

View Article

Answer by Matthew Price for Return XML from a controller's action in as an...

I've had to do this recently for a Sitecore project which uses a method to create an XmlDocument from a Sitecore Item and its children and returns it from the controller ActionResult as a File. My...

View Article

Answer by user2670714 for Return XML from a controller's action in as an...

Here is a simple way of doing it: var xml = new XDocument( new XElement("root", new XAttribute("version", "2.0"), new XElement("child", "Hello World!"))); MemoryStream ms = new MemoryStream();...

View Article

Answer by Casey for Return XML from a controller's action in as an ActionResult?

A simple option that will let you use streams and all that is return File(stream, "text/xml");.

View Article


Answer by sheir for Return XML from a controller's action in as an ActionResult?

Finally manage to get this work and thought I would document how here in the hopes of saving others the pain. EnvironmentVS2012SQL Server 2008R2.NET 4.5ASP.NET MVC4 (Razor)Windows 7Supported Web...

View Article

Answer by Drew Noakes for Return XML from a controller's action in as an...

If you're building the XML using the excellent Linq-to-XML framework, then this approach will be helpful.I create an XDocument in the action method.public ActionResult MyXmlAction(){ // Create your own...

View Article

Answer by Petr for Return XML from a controller's action in as an ActionResult?

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

View Article


Answer by Erik for Return XML from a controller's action in as an ActionResult?

If you are only interested to return xml through a request, and you have your xml "chunk", you can just do (as an action in your controller): public string Xml(){ Response.ContentType = "text/xml";...

View Article


Answer by Mahdi Taghizadeh for Return XML from a controller's action in as an...

There is a XmlResult (and much more) in MVC Contrib. Take a look at http://www.codeplex.com/MVCContrib

View Article

Answer by Luke Smith for Return XML from a controller's action in as an...

Use MVCContrib's XmlResult Action.For reference here is their code:public class XmlResult : ActionResult{ private object objectToSerialize; /// <summary> /// Initializes a new instance of the...

View Article

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

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...

View Article
Browsing latest articles
Browse All 12 View Live


Latest Images