Question

How do I create an rss feed in ASP.Net? Is there anything built in to support it? If not, what third-party tools are available?

I'm thinking webforms, not MVC, though I suppose since this isn't a traditional page the difference may be minimal.

Was it helpful?

Solution

For built-in, there's nothing stopping you from using XmlDocument or XDocument (3.5) to build up the required XML for RSS. It's more work than it's worth though.

I use the Argotic Syndication Framework and serve the feeds through Generic Handlers (.ashx) with the content type set to text/xml.

The RSSToolkit is also nice. It comes with an RSSDataSource control if you're into that sort of thing. It also includes a control that will automatically insert the meta tag required for feed autodiscovery in browsers. I found the build provider for creating feeds to be a little kludgey however.

OTHER TIPS

The .NET Framework 3.5 has added a SyndicationFeed Class which allows you to create and/or consume feeds in Atom 1.0 and RSS 2.0 formats.

SyndicationFeeds Class on MSDN

Here's an RSS framework created by a Microsoft developer: ASP.NET RSS Toolkit

Use one of the libraries available for generating the actual RSS. For example: http://www.rssdotnet.com/

If you check the code examples page at the bottom: http://www.rssdotnet.com/documents/code_examples.html you will find the code for clearing the content type in an ASP.net Page and outputting the RSS.

Something along the lines of (not tested, not compiled, just typed):

public void PageLoad()
{

// create channel
RssChannel _soChannel = new RssChannel();

// create item
RssItem _soItem = new RssItem();
_soItem.Title = "Answer";
_soItem.Description = "Example";
_soItem.PubDate = DateTime.Now.ToUniversalTime();

// add to channel
_soChannel.Items.Add(_soItem.);

// set channel props
_soChannel.Title = "Stack Overflow";
_soChannel.Description = "Great site.. jada jada jada";
_soChannel.LastBuildDate = DateTime.Now.ToUniversalTime();

// change type and send to output
RssFeed _f = new RssFeed();
_f.Channels.Add(channel);
Response.ContentType = "text/xml";
_f.Write(Response.OutputStream);
Response.End();

}

Hope that helps.

You could take a look at Argotic. It is a really cool framework.

http://www.codeplex.com/Argotic

Create an HTTP Handler to create a RSS feed

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top