Category

Umbraco

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)

Comments

Post a comment

Fields marked with an * (asterisk) are required


Recent Posts

News
Black Friday 2024 - FREE Umbraco Forms licence!

How to claim your FREE Umbr...

Umbraco
How to deploy Umbraco using Web Deploy from Azu...

How to deploy Umbraco using...

Umbraco
How to deploy Umbraco using Web Deploy from Git...

This blog post shows how yo...

Umbraco
Umbraco Medium Security Vulnerabilities - 22nd...

Security patches now availa...

News
UK Umbraco Hosting Now Available

You can now choose to host...