asp.net - how to create rss feed for a website? -


I have developed a webpage, now I want to create an RSS feed for my website. In my application, I have a module call movie news, which has the latest news of movie stars. Now I want to make an RSS feed for that module. News includes titles and descriptions. How can I create an RSS feed for my application? Here is the code that I use for my feed, this is just one. Shakes (generic handler)

), Which I point to on my website.

Remember to add this short html to your site:

  & lt; Link rel = "optional" type = "app / rss + xml" href = "/ rss.ashx" title = "feed feed for yourdomain.com" />  

And here is the full handler code:

  public class rssHandler: IHttpHandler {public void ProcessRequest (HttpContext reference) {var Response = context.Response; // Response feedback. Buffer = false; Response.Clear (); Response.ContentType = "application / rss + xml"; Response.Cache.SetExpires (DateTime.Now.AddMinutes (10)); Response.Cache.SetCacheability (HttpCacheability.Public); // XML Feed Author = XmlWriter.Create (Response.OutputStream)) Create an XML Writer to write it in the feed // Set the feed property syndication feed = new syndication ("yourdomain.com", "some details of your feed", new Uri ("http://www.yourdomain.com"); // add authors feed. Author. Add (new syndication partner ("yourmail@yourdomain.com", "your name", "http://www.yourdomain.com")); // Add categories News Type [] Categories = (News Type []) Enum.GetValues ​​(Typef (News Type)); // News Type I use is an NM, which is a Custom made Forehack (Diverse category in categories) {feed.Categories.Add (New Syndication Category (Category Gate Description)); } // Set Copyright Feed.Copyright = New Text Syndication Content ("© Copyright 200 9 Your Name"); // set generator feed Generator = "yourdomain.com"; // set language feed Language = "da-dk"; // Add Post Item List & lt; SyndicationItem & gt; Item = new list & lt; SyndicationItem & gt; (); Var News List = News Gatelatst (20); Forex Currency (Miscellaneous News in News List) {string url = GetShowUrl (News); Syndication item item = new syndication item (); Item.id = news.id.ToString (); Item.Title = TextSyndicationContent.CreatePlaintextContent (news.Name); Item.Content = SyndicationContent.CreateXhtmlContent (news.Content); Item.PublishDate = news.DateCreated.Value; Item.Categories.Add (new syndication category (news.NewsType.Value.GetDescription ())); Item.Links.Add (new syndication link (new ury (url), "optional", news .name, "text / html", 1000)); Items.Add (item); } Feed.Items = Items; // Write out the output buck to the feed 20 feed format format = new Rss20FeedFormatter (feed); Formatter.WriteTo (author); Writer.flush (); } Response.End (); } Public Hair IRUBL ({Return False}}} Private String GetShowUrl (News News) {// provides the correct full URL}}  

Comments