The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RSSFeedResult.cs 893B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.ServiceModel.Syndication;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using System.Xml;
  10. namespace Teknik.Helpers
  11. {
  12. public class RssResult : ActionResult
  13. {
  14. public SyndicationFeed Feed { get; set; }
  15. public RssResult() { }
  16. public RssResult(SyndicationFeed feed)
  17. {
  18. this.Feed = feed;
  19. }
  20. public override void ExecuteResult(ControllerContext context)
  21. {
  22. context.HttpContext.Response.ContentType = "application/rss+xml";
  23. Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed);
  24. using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
  25. {
  26. formatter.WriteTo(writer);
  27. }
  28. }
  29. }
  30. }