I needed to create an RSS feed last week and I ran across a video of Scott Hanselman using some built in functionality in .net. Here is the code...
And the Controller Method...
[HttpGet] public ActionResult RssFeed() { var items = new List<SyndicationItem>(); for (int i = 0; i < 20; i++) { var item = new SyndicationItem() { Id = Guid.NewGuid().ToString(), Title = SyndicationContent.CreatePlaintextContent(String.Format("My Title {0}", Guid.NewGuid())), Content = SyndicationContent.CreateHtmlContent("Content The stuff."), PublishDate = DateTime.Now }; item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri("http://www.google.com")));//Nothing alternate about it. It is the MAIN link for the item. items.Add(item); } return new RssFeed(title: "Greatness", items: items, contentType: "application/rss+xml", description: String.Format("Sooper Dooper {0}", Guid.NewGuid())); }
Can I see the SyndiactionItem class please?
http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationitem%28v=vs.110%29.aspx ... It is part of .net.