Reader Level:

Facebook RSS Feed Reader in MVC 4

By Abhimanyu K Vatsa on Dec 04, 2012
In this article you will learn how to setup the Facebook RSS Feed Reader in MVC 4.

In this article you will learn how to setup the Facebook RSS Feed Reader in MVC 4. Let's look at an image of what we will be creating in this article; see:

Where to find the RSS feed of my wall?

To find the RSS feed for you wall, login to your Facebook account and then navigate to the URL In the top you will find a link to open the RSS feed page.

Once you are there, you will notice the following page and its root <item>.

Now let's get started with the coding.

First of all create the following model classes.

    public class FacebookRSS


        public string Title { getset; }

        public string Link { getset; }

        public string Description { getset; }

        public string PubDate { getset; }


    public class FBRssReader


        public static IEnumerable<FacebookRSS> GetFeed()


            var client = new WebClient();

            client.Headers.Add("user-agent""Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

            var xmlData = client.DownloadString("");  //remember to update this URL

            XDocument xml = XDocument.Parse(xmlData);

            var FBUpdates = (from story in xml.Descendants("item")

                            select new FacebookRSS


                                Title = ((string)story.Element("title")),

                                Link = ((string)story.Element("link")),

                                Description = ((string)story.Element("description")),

                                PubDate = ((string)story.Element("pubDate"))


            return FBUpdates;



In the above code, we have two classes. The very first one "FacebookRSS" has a couple of properties and the second one "FBRssReader" has a method "GetFeed()" and this method will return IEnumerable data. The rest of the code is pretty simple and you can understand it easily. When you are done with the model, go ahead and create or update the existing controller.

        public ActionResult Index()


            ViewBag.FBFeed = RSS_Reader.Models.FBRssReader.GetFeed();

            return View();


Now, go ahead and update the view that will show our result on the web page.




        <h3>Facebook Updates</h3>



@foreach (var item in ViewBag.FBFeed)




        <b>@item.Title</b><a href="@item.Link" target="_blank"> more </a> on @Convert.ToDateTime(item.PubDate)

        <br />






And now, I'm done with everything and am ready to run the application, here is my output screen:

Hope this helps. Thanks.

Abhimanyu K Vatsa
Abhimanyu K Vatsa

Microsoft MVP | Author | IT Faculty | Student of M.Tech. IT | Blogs at ITORIAN.COM

Personal Blog:



Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.

Trending up