RSS Feed

Topics: Developer Forum
Aug 18, 2006 at 2:45 AM
I came up with a simple RSS feed that could probably be improved on quite a bit. I am using RSS.NET (http://www.rssdotnet.com/) as the generator. Below is the code.

New rss.aspx file:

using Rss;

public partial class rss : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataLayer dl = new DataLayer ( );
DataTable rawItems = dl.GetDataTable ( "sb_GetPosts" );
rawItems.DefaultView.Sort = "EntryDate";
DataView dv = rawItems.DefaultView;
DataTable items = dv.ToTable ( );

Rss.RssChannel channel = new Rss.RssChannel ( );
channel.Title = Settings.GetSetting ( "SiteTitle", "Simple Blog .Net" );
channel.Description = Settings.GetSetting ( "SiteSubTitle", "Blogging Made Easy" );
channel.Generator = "RSS.NET";
channel.Language = "en-us";

channel.Link = new Uri ( this.Request.Url.OriginalString.Replace ( this.Request.Url.PathAndQuery, "" ) );
channel.TimeToLive = 30;

if ( items.Rows.Count > 0 )
channel.LastBuildDate = (DateTime)items.Rows0"EntryDate";
else
channel.LastBuildDate = DateTime.Now;

channel.ManagingEditor = "me@brian-rogers.com";
channel.WebMaster = "me@brian-rogers.com";

foreach ( DataRow row in items.Rows )
{
Rss.RssItem item = new Rss.RssItem();
item.Title = row"Title".ToString ( );
item.Description = row"Body".ToString ( );
item.PubDate = (DateTime)row"EntryDate";
channel.Items.Add ( item );
}

RssFeed feed = new RssFeed ( );
feed.Channels.Add ( channel );
this.Response.ContentType = "text/xml";
feed.Write ( this.Response.OutputStream );
this.Response.End ( );
}
}
Coordinator
Aug 19, 2006 at 12:27 AM
Thanks, I'll add that code in.
Coordinator
Aug 24, 2006 at 3:10 PM
I noticed that RSSDotNet uses NUnit for Unit Testing, do you know of a way to include RSSDotNet functionality w/o having to include the NUnit framework?
Sep 11, 2006 at 5:26 PM
Is a new version with RSS.NEt will be available soon?

Or how can I download the RSS.NET I will implement it in the project myself.