Created
August 10, 2017 14:36
-
-
Save MichaelaIvanova/0ba00869a931c751f09bcae539e3260c to your computer and use it in GitHub Desktop.
rss, custom action result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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