Skip to content

Instantly share code, notes, and snippets.

@MichaelaIvanova
Created August 10, 2017 14:36
Show Gist options
  • Save MichaelaIvanova/0ba00869a931c751f09bcae539e3260c to your computer and use it in GitHub Desktop.
Save MichaelaIvanova/0ba00869a931c751f09bcae539e3260c to your computer and use it in GitHub Desktop.
rss, custom action result
public class RssActionResult : ActionResult
{
public SyndicationFeed Feed { get; set; }
public override void ExecuteResult(ControllerContext context)
{
context.HttpContext.Response.ContentType = "application/rss+xml";
var rssFormatter = new Rss20FeedFormatter(Feed);
using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
{
rssFormatter.WriteTo(writer);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment