Esempio n. 1
0
        public static SyndicationFeed GetPostFeed()
        {
            SyndicationFeed postfeed = Feeds.GetFeed();

            postfeed.Title       = new TextSyndicationContent("Key Mapper Developer Blog");
            postfeed.Description = new TextSyndicationContent("Post feed for the Key Mapper Developer Blog");

            Collection <Post>      posts = Post.GetAllPosts(CommentType.Approved);
            List <SyndicationItem> items = new List <SyndicationItem>();

            foreach (Post p in posts)
            {
                SyndicationItem item = new SyndicationItem();
                item.Id      = p.Id.ToString();
                item.Title   = new TextSyndicationContent(p.Title);
                item.Content = new TextSyndicationContent(p.Body);

                SyndicationLink itemlink = new SyndicationLink();
                itemlink.Title = "Key Mapper Blog";
                itemlink.Uri   = new Uri("http://justkeepswimming.net/keymapper/default.aspx?p="
                                         + p.Id.ToString() + ".aspx");
                item.Links.Add(itemlink);

                SyndicationPerson person = new SyndicationPerson();
                person.Name  = "Stuart Dunkeld";
                person.Email = "*****@*****.**";
                item.Authors.Add(person);

                items.Add(item);
            }

            postfeed.Items = items;
            return(postfeed);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SyndicationFeed feed = Feeds.GetPostFeed();

            Response.Clear();
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "text/xml";

            using (XmlWriter rssWriter = XmlWriter.Create(Response.Output))
            {
                Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
                rssFormatter.WriteTo(rssWriter);
            }

            Response.End();
        }