ASP.NET MVC ContentResult or return an XDocument

Is there any effective difference between this:

    public class FeedController : Controller
    {
        private IBlogFeed feed;
        public FeedController(IBlogFeed feed)
        {
            this.feed = feed;
        }
        public XDocument Index()
        {
            Response.ClearHeaders();
            Response.AddHeader("Content-Type", "text/xml");
            return feed.blogFeed();
        }
    }

and this:

	public class FeedController : Controller
	{
		private IBlogFeed feed;
		public FeedController(IBlogFeed _feed)
		{
			this.feed = _feed;
		}
		public ContentResult Index()
		{
			return Content(feed.blogFeed().ToString(), "application/rss+xml");
		}
	}

From the browser’s point of view the results are identical. Both return the XML feed as text/xml (even though I expected the content type to be application/rss-xml in the second example).

BlogFeed() returns an XDocument:

		public XDocument blogFeed()
		{

			const string url = "http://yoursite.com/article/{0}";
			using (dataContext writeRSS = new dataContext())
			{
				var items = (from p in writeRSS.Posts
							 select new
							 {
								 ID = p.postTitle.Replace(" ", "-"),
								 Head = p.postTitle,
								 Intro = (p.content.IndexOf("<!-- teaser -->") != -1) ? p.content.Substring(0, p.content.IndexOf("<!-- teaser -->")) : p.content,
								 CreatedDate = p.created
							 }).AsEnumerable().OrderByDescending(c => c.CreatedDate).Take(5);
				var rss = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
				  new XElement("rss",
					new XAttribute("version", "2.0"),
					  new XElement("channel",
						new XElement("title", String.Format("{0} News Feed", ConfigService.companyName)),
						new XElement("link", "http://newcastlechurchofChrist.com/feed.xml"),
						new XElement("description", String.Format("Latest additions to {0}", ConfigService.companyName)),
						new XElement("copyright", String.Format("&#169; {0}, {1}. All rights reserved", DateTime.Now.Year, ConfigService.companyName)),
					  from item in items
					  select
					  new XElement("item",
						new XElement("title", item.Head),
						new XElement("description", item.Intro),
						new XElement("link", String.Format(url, item.ID)),
						new XElement("pubDate", String.Format("{0:r}",item.CreatedDate))

					  )
					)
				  )
				);
				
				return rss;
			}
		}

Isn’t there an XmlResult?

I think that’s a third party addition.

The first snippet is what I had before I discovered ContentResult, the only reason I changed it was because it seems to be the purpose of ContentResult. I was just wondering if the compiler handles both situations the same way.

The problem with the first snippet is your controller is accessing the Request object and breaking away from Mvc conventions. I would avoid it like the plague and return some form of ActionResult. There is an XmlResult in the MvcContrib project that I would use

How does XmlResult differ from ContentResult?

Wait, can you explain this further? What MVC convention is this violating? Are you referring to the manipulating the response header?