Yesterday I received the question to add an RSS feed to one of our internal MCMS Web sites.
At that moment I did not know more about RSS as that this blog has an RSS feed to be able to keep updated with my writings. 😉
So I searched for a document explaining what RSS is and how it works. I found this very easy to read document which is a very good starter when trying to write an RSS feed: http://www.feedvalidator.org/docs/rss2.html
To sum up, an RSS feed is very similar to a MCMS summary page. Major differences: the content is served as XML rather than html. but Html can be embedded if propertly encoded.
As the RSS feed should give information about recent changes to the MCMS site I used the NewPosting method of the searches object and returned a summary of the content.
To integrate the RSS feed nicely into the site I created an RSS channel below the root of the Web site and bound the ASP.NET Web form that generates the Feed as Channel Rendering Script to this channel.
Here is the actual implementation:
/// Summary description for RSS.
public class RSS : System.Web.UI.Page
private string GetPostingSummary(Posting p)
if (p.Placeholders[“Summary”] != null)
HtmlPlaceholder phSummary = (HtmlPlaceholder)p.Placeholders[“Summary”];
private string GenerateRssXml()
MemoryStream mem = new MemoryStream();
XmlTextWriter Xmlwriter = new XmlTextWriter(mem, Encoding.UTF8);
Xmlwriter.WriteElementString(“title”,”Title of your Web site”);
Xmlwriter.WriteElementString(“copyright”,”© Your Corporation. All rights reserved.”);
Xmlwriter.WriteElementString(“description”,”Description of your Web site”);
Xmlwriter.WriteElementString(“managingEditor”,”email of your responsible Editor”);
Xmlwriter.WriteElementString(“webMaster”,”email of your responsible Webmaster”);
Xmlwriter.WriteElementString(“generator”,”Stefan’s RSS feeder 184.108.40.206″);
PostingCollection pc = CmsHttpContext.Current.Searches.NewPostings(20);
foreach (Posting p in pc)
if (p.Path.ToLower().StartsWith(“/channels/publicchannel”)) // I don’t want include all channels here
// date needs to be in this format!
// guid needs to have the isPermaLink=false attribute for some rss readers
mem.Position = 0;
StreamReader reader = new StreamReader(mem);
private void Page_Load(object sender, System.EventArgs e)
Response.ContentType = “text/xml; charset=utf-8”; // its Xml, not Html
protected override void Render( HtmlTextWriter writer)
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
/// Required method for Designer support – do not modify
/// the contents of this method with the code editor.
private void InitializeComponent()
this.Load += new System.EventHandler(this.Page_Load);
I decided to use the last modified date as published date as this was our business requirement. If you like you can also choose the creation date instead.
The code above is pretty simple. You might have to adjust it to meet your requirements if different placeholders on different templates should be returned.
As you can see MCMS makes it easy for you to create an RSS feed for content syndication or for whatever reason your would like to have this nice feature.