16

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.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794

6 Answers6

11

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

6

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
  • 77,456
  • 30
  • 160
  • 194
4

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

John Calsbeek
  • 35,947
  • 7
  • 94
  • 101
2

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.

Alex Duggleby
  • 7,948
  • 5
  • 37
  • 44
2

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

http://www.codeplex.com/Argotic

Tom Alderman
  • 305
  • 8
  • 17
-1

Create an HTTP Handler to create a RSS feed

Bhaskar
  • 10,537
  • 6
  • 53
  • 64