0

Hello All, I have a web application(In MVC 2.0) for time attendance system.There is a new requirement to implement the RSS Feed in application.

I have written the following line of code in RSSFeedController C#:-

  public ActionResult GetRSSFeed(int id)
    {
        string strFeed = string.Empty;
        if (id == 1)
            strFeed = "http://timesofindia.indiatimes.com/rssfeeds/296589292.cms";
        else if (id == 2)
            strFeed = "http://rss.logicalexpressions.com/LogicalTips.rss";

        else if (id == 3)
            strFeed = "http://rss.logicalexpressions.com/LogicalTips.rss";

        using (XmlReader reader = XmlReader.Create(strFeed))
        {
            SyndicationFeed rssData = SyndicationFeed.Load(reader);
            return View(rssData);
        }
        //return View();
    }

This code is working fine.But I just want to know how I can decide the no of news to be show in page

thanks in advance

tereško
  • 58,060
  • 25
  • 98
  • 150
Suri
  • 518
  • 2
  • 6
  • 20

1 Answers1

0

Define a number in your web.config/App.config.

And, when you're sending rssfeed for rendering on view use this pre-defined number from configuration file i.e.

return View(rssData.Items.Take(NoOfFeeds));


 public int NoOfFeeds
    {
        get 
        { 
            return Convert.ToInt32(ConfigurationManager.AppSettings["Feeds"]);
        }
    }

hope this helps !!

Rahul20
  • 26
  • 3
  • I just want to know how to mention it in the link of RSS Feed? – Suri Jan 28 '13 at 19:33
  • could you please elaborate your problem more? I didn't understand properly. – Rahul20 Jan 29 '13 at 08:28
  • I mean how to decide the no of records/news to be read from the RSS feed. Suppose I want to read the 30 links then how I would mention it in the url. – Suri Jan 29 '13 at 15:31
  • I guess you're providing the choice to user for selecting the feed channel i.e. id =1,2,3. Then, Why don't you letting user to select the number records they want to display? – Rahul20 Jan 30 '13 at 10:14