Creating the Site - Part 3: RSS for the blog

by Graeme
I went through a few versions of getting the RSS feed of the blog into the application, before coming across a very neat way of adding subscriptions to your MVC application.

First I thought I could use the ASP.NET RSS Toolkit (http://www.codeplex.com/ASPNETRSSToolkit). It would have worked well but would have been an external dependency and I would have also needed to import it's handler and overall it wasn't that neat a fit into the MVC solution.

Next I did the obvious solution, which was to create a simple View that instead of outputting html, generated the RSS xml. This solution works well and as RSS isn't too complex it didn't take much time to implement. The only issue, is the view pages are designed to be HTML and outputting xml was a bit of an issue.
Then I came across this excellent solution by ekampf, where by you use the SyndicationFeed classes in WCF to format the Rss xml for you and then create your own RssActionResult to return this formatted document - no need for a view, minimal code to create the feed - excellent!

So the result of this looks rather like so:


Using this elegant solution it was also trivial to create an atom feed from the same syndication feed I'd already created, I just needed to create another ActionResult to return the atom formatted feed.


The last step was to sign up to Feed Burner and add this as a link to the site so that people can find the RSS feeds.

Posted at 7/6/2009 10:45:52 PM | Comments (0)
Submit a Comment:


© 2010 Graeme Finn