Whilst building the new UmbHost website in Umbraco V9, I decided I would move any Umbraco blog posts, or anything hosting / server related to the blog over here.

Of course this meant I needed to add an RSS / Atom feed to the site, on the Umbraco Discord server I came across a really useful tip, we can use Route in a surface controller, this meant I could use blog/feed.rss and blog/feed.atom easily.

Below you will find the code I have used to do this, I'm sure there are improvements which can be made (please do let me know in the comments), I have also set the feeds to be cached every 15 minutes.

The dot net package called System.ServiceModel.Syndication will need to be installed into your project using the following command

dotnet add package System.ServiceModel.Syndication

I have also added a checkbox property to my blog post document type, with an alias of hideFromXmlSyndication this is used to hide the blog item from the feeds, this defaults to false

First we want to create an interface called ISyndicationXmlService.cs

Next create the service called SyndicationXmlService.cs

Now we want to register the service using a composer called RegisterSyndicationXmlServiceComposer.cs

Finally we need a surface controller to return the feeds called SyndicationSurfaceController.cs
In here you can change the Route to your preferred url and changing the ResponseCache will change the length of time the feed is cached for (in seconds)


Post a comment

Fields marked with an * (asterisk) are required

Recent Posts

UmbHost Limited is now a Silver Umbraco Partner

We are now officially a Sil...

How to pass a Content Security Nonce (CSP) to G...

How to use a CSP nonce with...

UmbCheckout 1.0.0 & UmbCheckout.StarterKit.Stri...

The stable version of UmbCh...

Voting is now open for the Green Business of th...

We've been shortlisted! - P...

We have been shortlisted in The Petersfield Awa...

We have been shortlisted fo...

Browse Umbraco Hosting

Umbraco Hosting Starting At £20.00/month