How would you generate RSS using ASP.Net MVC? I have the data in the database already and I'll transform it as necessary. My first approach is to create an RSS template that I use as a view, but that seems error prone and since RSS is a structured format there could be a class that I set some properties and generates RSS. Is there such a thing? How would you do it?
+4
A:
Use WCF System.ServiceModel.Syndication
namespace for which you need to add System.ServiceMode.Web to your references. That handles the whole thing automatically:
using System.ServiceModel.Syndication;
// ...
var rss = new SyndicationFeed(...);
...
var formatter = new Rss20FeedFormatter(rss);
formatter.WriteTo(xmlWriter);
Mehrdad Afshari
2009-06-22 23:08:17
+5
A:
Here's an interesting article - http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/
It creates an RssActionResult class that sets the content type, and Syndication items to render the View.
David Liddle
2009-06-22 23:10:02
+1
A:
Here are a couple links:
http://stackoverflow.com/questions/11915/rss-feeds-in-asp-net-mvc
http://www.developerzen.com/2009/01/11/aspnet-mvc-rss-feed-action-result/
Dennis Palmer
2009-06-22 23:13:42
@David beat me to it!
Dennis Palmer
2009-06-22 23:14:17