Generate RSS/Atom feeds using FeedManager.dll
FeedManager is a custom RSS/Atom Syndication generator that allows for quick and efficient generation of RSS/Atom feeds. Just reference the dll in your web applications, then write a few lines of code to expose your data to external applications/web sites.
The rsstoolkit exists for generating syndicated feeds on the fly, but if, like me, you have had issues porting the toolkit between project types and have to keep messing with web.config settings to get it to work, then the feedmanager.dll approach might work for you.
Here's how to get started:
- Download the cutsom FeedManager.dll here.
- Add a reference to the dll from your solution, or simply copy the file to your application's Bin directory
- Open up a web page, and in the code behind, create an instance of the FeedManager.FeedCreator class
- Set Properties on the FeedCreator class (title, author etc)
- Add FeedItems to the FeedCreator class. This will typically be data obtained from a dataset.
- Call the GenerateFeed() Method on the FeedManager.FeedCreator class to generate your feed.
protected void Page_Load(object sender, EventArgs e)
{
using (FeedManager.FeedCreator aFeed = new FeedManager.FeedCreator(FeedType.RSS))
{
aFeed.FeedUrl = "http://www.solid2.com";
aFeed.FeedTitle = "My RSS Feed Title";
aFeed.FeedDescription = "My RSS Feed Description";
aFeed.FeedCopyright = "(c) 2009. All rights reserved";
aFeed.FeedImage = "http://contoso/image.jpg";
//add items to the feed
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "first Item", "first summary", "Lorem ipsum dolor sit amet.", "thefirstlink", "1.aspx", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "second Item", "second summary", "Lorem ipsum dolor sit amet.", "thesecondlink", "http://www.solid2.com", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "third Item", "third summary", "Lorem ipsum dolor sit amet.", "thethirdlink", "http://www.solid2.com", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "fourth Item", "fourth summary", "Lorem ipsum dolor sit amet.", "thefourthlink", "http://www.solid2.com", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "fifth Item", "fifth summary", "Lorem ipsum dolor sit amet.", "thefifthlink", "http://www.solid2.com", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
aFeed.AddItem(new FeedItem(Guid.NewGuid().ToString(), "sixth Item", "sixth summary", "Lorem ipsum dolor sit amet.", "thesixthlink", "http://www.solid2.com", DateTime.Now.ToString(), "Jaycent", "info@solid2.com"));
//generate the feed, send results to browser window.
aFeed.GenerateFeed();
}
}
Navigate to the page to view the ouput!
Play around with setting the FeedType setting in the constructor between Feedtype.RSS and FeedType.Atom. View the source of the generated file to examine the difference in the output. For an excellent comparison article for ATOM vs RSS, see Aaron Brazell article here.
-
For source code, contact info@solid2.com or jaycentdrysdale@hotmail.com
Happy new year, and happy programming!