views:

831

answers:

9
+10  Q: 

ASP.Net RSS feed

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.

+4  A: 

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

John Calsbeek
+6  A: 

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.

John Sheehan
+2  A: 

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.

AlexDuggleby
A: 

While investigating my own question, I found this article very helpful.

Joel Coehoorn
+2  A: 

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

http://www.codeplex.com/Argotic

Tom Alderman
+8  A: 

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

A: 

Here's a great tutorial, aptly titled "How to create a syndication feed for your website" http://dotnetslackers.com/articles/aspnet/How-to-create-a-syndication-feed-for-your-website.aspx

Ryan
A: 

Create an HTTP Handler to create a RSS feed

Bhaskar
+1  A: 

Take a look at some code I gave in another question, here in SO.

ileon