SyndicationFeedResult 源代码

原文地址:http://code.google.com/p/netfx/source/browse/trunk/Source/Web/Mvc/SyndicationFeedResult.cs?r=73

/* 
 * Dependencies: 
 *              System.Web.Abstractions
 *              System.Web.Mvc
 *              System.Web.Routing
 *              System.ServiceModel.Web
 * Authors: Juan Wajnerman - jwajnerman@manas.com.ar
 */

using System.ServiceModel.Syndication;
using System.Xml;

namespace System.Web.Mvc
{
        public class SyndicationFeedResult : ActionResult
        {
                SyndicationFeed feed;
                string format;

                public SyndicationFeedResult(SyndicationFeed feed, string format)
                {
                        this.feed = feed;
                        this.format = format;
                }

                public SyndicationFeedResult(SyndicationFeed feed)
                        : this(feed, "atom")
                {
                }

                public override void ExecuteResult(ControllerContext context)
                {
                        context.HttpContext.Response.ContentType = "text/xml";
                        SyndicationFeedFormatter f = format == "atom" ?
                                        (SyndicationFeedFormatter)new Atom10FeedFormatter(feed) :
                                        (SyndicationFeedFormatter)new Rss20FeedFormatter(feed);
                        using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
                                f.WriteTo(writer);
                }
        }
}

请参考:http://weblogs.asp.net/britchie/archive/2011/02/21/serving-up-rss-feed-in-mvc-using-wcf-syndication.aspx

相关文章:

  • 2021-08-11
  • 2021-06-11
  • 2021-08-17
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-09-01
  • 2022-02-21
猜你喜欢
  • 2021-12-02
  • 2022-12-23
  • 2021-08-18
  • 2022-12-23
  • 2021-09-23
  • 2021-11-05
  • 2021-06-13
相关资源
相似解决方案