How to programmatically configure RSS feed for a list in SharePoint

Here's another interesting story. SharePoint will overwrite all the RSS columns you might have setup for a list.
One of the tasks I was working was to process across all the list in all the sites of a specific site collection, then enable RSS settings for each list and set a predefined group of columns as the RSS output. Once that's done, one could easily go to the list settings and verify them like the figure below:
The whole process executed with no problems. No error messages and no warnings.
However, when I went to take a look at my modified RSS settings that's the screen I saw:
It means, nothing was setup the way I planned. Apparently nothing happened when the code executed.
So I went to debug and inspected the line one by one. No error and when I went to see the screen, that's what I've got:
Yep. Everything was there and working.
How come it fails in first place and worked well on my second try?
This behavior continued on and on and and on, with many other libraries. Fails the first time, succeed in the second. So I went to look at the data definition using SharePoint Explorer. For a brand new library, that's what I saw:
And that's how it looks like once I execute my code to create a new RSS feed:
All right. It means the RSS is actually there. So I went to see the RSS settings in the page and guess what...That's what I see:
The RSS is blank again!!!
Then I came back to see using the explorer and...
Voila... something is kick-starting the creation of a brand new RSS setting and overwriting my one for usage.
I had a guess but it was just too weird to believe: SharePoint creates automatically a RSS feed for the first time and only during the first time an user visits the settings page.
I decided to debug the page and try to understand what SharePoint calls are made via UI. I've got my hands on the _layouts/listsyndication.aspx page from SharePoint
and I attached a debugger to it. I chose a brand new document library to test my theory and during the first page load I got this breakpoint:
During the page load there is javascript call to the server triggering SPList.EnsureRssSettings()
Then using .NET Reflector I opened the Microsoft.Sharepoint.Dll version 12 and found the method signature:
Looking inside the method I noticed:
  1. SharePoint does use a hardcoded string ("RssView") to control the RSS name and which view is a RSS type.
  2. EnsureRssSettings in fact creates a brand new Rss feed for you, without your request.
So, debriefing the case. When you open up the settings page, the listsyndication.aspx page automatically performs a call to SPList.EnsureRssSettings() which automatically creates a RSS feed (if syndication is enabled) and makes it invisible (see property Hidden=true). When my code ran, it created another view with the same name RssView, but actually the web address was different. The next time the code executed, I was not working anymore with my view but with the previously automatically created Rss from SharePoint.
Closing up the case: Next time you need to create a Rss feed, you don't have to create a view. You just have to make sure you call in your code SPList.EnableRssSettings() and then go ahead and modify the SPList.View called "RssView"
Now, the code:
and then to save the Rss feed...
See you later,



  1.; You saved my day again.

  2. AnonymousJuly 31, 2012

    Where do I start when I follow your advice? It seems as though it starts in the middle?

  3. Hello
    I am trying to create RSS Feed from sharepoint calender list programattically.
    Can you provide me the sample code if you have ?