What is RSS?
RSS is a family of web feed formats used to publish frequently updated digital content, such as blogs, news feeds or podcasts.
Users of RSS content use software programs called "feed readers" or "feed aggregators". The user subscribes to a feed by entering a link of the feed into the reader program. The reader can then check the user's subscribed feeds to see if any of those feeds have new content since the last time it was checked, and, if so, retrieve that content and present it to the user.
Wikipedia article on RSS
RSS has become the de-facto standard for syndication of content over the Internet. Feeds from blogs, news sites or even standard business systems is now common
and the orange "feed icon"
is widely recognises as a link to syndicated content.
In BackgroundMotion we allow any view of the contribution data to be subscribed to through RSS.
We used the ASP.NET RSS Toolkit created by Dmitry Robsman which allowed us to add
support for RSS in about 10 minutes!
Integrating RSS into your applications
Syndication of content through RSS is done by creating an XML feed which complies with the RSS 0.91 or 2.0 formats. Typically
most people today use RSS 2.0. Rather than having to understand the format yourself, you can use the same open source library
that we have used on BackgroundMotion and leverage it to create the XML you will need to publish your content.
To get started, download the latest version of the ASP.NET RSS Toolkit project from CodePlex.
Step 1
You will need to include a reference to RSSToolkit.dll in your solution. The classes we are going to be working with are
GenericRssChannel,
and
GenericRssElement.
Step 2
An RSS feed contains a number of syndicated content items and is wrapped up in a channel element which is a container which describes the metadata
about the feed which you are viewing. To represent this using the toolkit we create a new GenericRssChannel and assign some specific values to it, for example:
GenericRssChannel rssFeed = new GenericRssChannel();
rssFeed["title"] = channel;
rssFeed["link"] = "http://www.backgroundmotion.com";
rssFeed["description"] = description;
rssFeed["copyright"] = "(c) 2007 - Mindscape";
rssFeed["lastBuildDate"] = DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss");
rssFeed["generator"] = "Background Motion RSS";
rssFeed["managingEditor"] = "webmaster@backgroundmotion.com";
rssFeed["webMaster"] = "webmaster@backgroundmotion.com";
Step 3
For each item in our collection of content, we create a GenericRssElement and assign the appropriate content values. The item is then added to the feed.
GenericRssElement item = new GenericRssElement();
item["title"] = contribution.Title;
item["description"] = contribution.Description;
item["pubDate"] = contribution.AddedOn.ToString("ddd, dd MMM yyyy HH:mm:ss");
item["category"] = contribution.ContentType.Description;
item["guid"] = contribution.Id.ToString();
Step 4
To return an XML document, we can call the SaveAsXml method on the GenericRssChannel class. This can then be written to the output
stream of a web request to provide a consumable feed.
Tip: In a future release of the .NET Framework there will be a new framework library called System.Syndication which will
provide standard platform support with .NET for syndication of content through any of the standard syndication formats.