{"id":22,"date":"2007-11-28T16:02:00","date_gmt":"2007-11-28T20:02:00","guid":{"rendered":"http:\/\/warriormill.com\/?p=22"},"modified":"2011-12-14T21:47:44","modified_gmt":"2011-12-15T01:47:44","slug":"making-an-aspnet-page-an-rss-feed","status":"publish","type":"post","link":"https:\/\/warriormill.com\/2007\/11\/making-an-aspnet-page-an-rss-feed\/","title":{"rendered":"Making an ASP.NET page an Rss feed"},"content":{"rendered":"

The following code will give any page the ability to be used as an rss feed automatically<\/p>\n

[code lang=”csharp”]
\nPublic class BasePage : System.Web.UI.Page
\n{
\n\tprotected override void Render(HtmlTextWriter writer)
\n\t{
\n\t\tif (Request.QueryString["rss"] == "true")
\n\t\t{
\n\t\t\tSystem.Text.StringBuilder sb = new System.Text.StringBuilder();
\n\t\t\tSystem.IO.StringWriter sw = new System.IO.StringWriter(sb);
\n\t\t\tHtmlTextWriter nw = new HtmlTextWriter(sw);
\n\t\t\tResponse.Clear();
\n\t\t\twriter.Write("");
\n\t\t\twriter.Write("");
\n\t\t\twriter.Write(" ");
\n\t\t\twriter.Write(" " + this.Request.Url.AbsoluteUri.ToString() + "");
\n\t\t\twriter.Write(" ");
\n\t\t\twriter.Write(" en-us");
\n\t\t\twriter.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
\n\t\t\twriter.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
\n\t\t\twriter.Write(" ");
\n\t\t\twriter.Write(" Dynamic page generator");<\/p>\n

\t\t\twriter.Write(" ");writer.Write(" " + this.Request.Url.AbsoluteUri.ToString() + "");
\n\t\t\twriter.Write(" ");
\n\t\t\tRenderChildren(nw);
\n\t\t\tif (sb.ToString().IndexOf(" ") > 0)
\n\t\t\twriter.Write(Util.StripHTML(sb.ToString().Substring(sb.ToString().IndexOf(""))));
\n\t\t\telse
\n\t\t\twriter.Write(Util.StripHTML(sb.ToString()));
\n\t\t\twriter.Write("");
\n\t\t\twriter.Write(" " + DateTime.Now.ToUniversalTime().ToString() + "");
\n\t\t\tGuid g = new Guid();
\n\t\t\twriter.Write(" " + g.ToString() + "");
\n\t\t\twriter.Write(" ");writer.Write(" ");
\n\t\t}
\n\t\telse
\n\t\t{
\n\t\t\tbase.Render(writer);
\n\t\t}
\n\t}<\/p>\n

}
\n\tpublic static class Util
\n\t{
\n\t\tpublic static string StripHTML(string htmlString)
\n\t\t{
\n\t\t\tstring pattern = @"<(.\\n)*?>";
\n\t\t\treturn Regex.Replace(htmlString.Replace(" ", " "), pattern, string.Empty);
\n\t\t}
\n\t}
\n[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"

The following code will give any page the ability to be used as an rss feed automatically [code lang=”csharp”] Public class BasePage : System.Web.UI.Page { protected override void Render(HtmlTextWriter writer) { if (Request.QueryString["rss"] == "true") { System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter sw = new System.IO.StringWriter(sb); HtmlTextWriter nw = new HtmlTextWriter(sw); Response.Clear(); writer.Write(""); writer.Write(""); writer.Write(" […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[60,61,63],"_links":{"self":[{"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/posts\/22"}],"collection":[{"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":5,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/posts\/22\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/warriormill.com\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}