This project has moved. For the latest updates, please go here.

Handling Errors and problem returning complete list of Rss items

Topics: Developer Forum, User Forum
Mar 19, 2008 at 1:40 PM
Hi there,

I want to catch errors if the RSS Feed I am consuming is down. To do this I have used the following code:


protected void Page_Load(object sender, EventArgs e)
{


}

protected void RssDataSource_Init(object sender, EventArgs e)
{
try
{
RssDataSource myRssDataSource = new RssDataSource();

myRssDataSource.Url = new System.Uri(System.Configuration.ConfigurationManager.AppSettings"AflRssFeed").ToString();
DataList1.DataSourceID = RssDataSource1.ID.ToString();
DataList1.DataBind();
}
catch (Exception ex)
{
Label1.Text = "RSS Feed currently unavailable";
Label1.Visible = true;

}

}

However, my DataGrid now only shows several items of the Rss feed (old cached ones?) and not the newer news articles. If i add the URL attribute directly on the page to the RssDataSource URL property as below:

Url="http://xml.afl.com.au/rss.aspx?rssid=2"

then the problem is resolved...however I am back to square one in that if the RssFeed goes down, my entire page will fall over

My question is;
1. Can anyone explain why the RssDataSource only returns several items and not the complete list when i use the init method above?
2. Is there a better way to handle an error?

thank you.