I wrote this blog to give a possible workaround for RSS Web Part problems with certain feeds.
Did you ever try to connect a list feed to a SharePoint RSS feed web part? Well, I did, and it doesn’t work. The web part returned me a redirect error on public Internet sites and an authentication problem on secure Intranet sites.
The RSS web part is not able to handle secure RSS connections. After some debugging the problem of the redirect error was found in the fact, that certain RSS feeds are trying to return a cookie, which a web part normally does not accept. Because the cookie is not set, the RSS generator keeps redirecting the download request.
The cookie and authentication problems do not only apply to the SharePoint list feed, but also to a lot of other feeds on the internet.
The work around
To get correct RSS feeds in the standard SharePoint RSS feed web part, I’ve chosen to develop a small “proxy” handler to access the feed in Visual Studio.
To create the proxy, we’ll start with adding a “Generic handler” file to an empty web project. The generic handler item uses the extension .ashx. I won’t recommend using the normal “Web Form” (aspx) template, because it uses more resources than the simple handler. We simply don’t need all the page rendering technology of a web form to return some xml. Keep it light and simple!
The generic handler implements the IHttpHandler which defines 2 functions. The “IsReusable” boolean function is used to indicate if a single instantiation of our IHttpHandler can be used to process multiple concurrent requests. We will just leave this value on it’s default “false” value. The second function, the “ProcessRequest” function, is where all the magic happens.
In our “ProcessRequest” function we’ll add our code to download a RSS feed. Once we downloaded the feed we will pass it back to the browser or web part. Because we are controlling the download process of the RSS feed, we can now add additional code, that the standard web parts don’t have. We can add a cookie bag to accept cookies and we can set a higher redirect value to allow more redirects. If you bought a news RSS for your intranet which requires login credentials you would also be able to add them to the proxy code.
[WebService(Namespace = “https://edwin.vriethoff.net/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class RSSFeed : IHttpHandler
public void ProcessRequest(HttpContext context)
XmlReader feedReader = null;
//Create and configure httpRequest
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest
httpRequest.MaximumAutomaticRedirections = 15;
httpRequest.UserAgent = “Mozilla/4.0 (compatible; MSIE 6.0;
Windows NT 5.1)”;
httpRequest.CookieContainer = new CookieContainer();
//Set XMLReader settings
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.IgnoreWhitespace = true;
//Download and load the feed
feedReader = XmlReader.Create(httpRequest
XmlDocument rssDoc = new XmlDocument();
//Output the xml
context.Response.ContentType = “text/xml”;
public bool IsReusable
Of course, in our real project, we made the proxy a lot smarter. For example, I won’t recommend using a hardcoded RSS url inside the code.
If we host the proxy inside a secured SharePoint environment, there is a nasty little problem left; The standard RSS web part is not able to download RSS feeds that require login credentials. Because the proxy is located inside the secure SharePoint environment, IIS requests credentials from the web part. To fix this last step we have to tell IIS that the proxy file is allowed to be accessed anonymously.
Open the IIS manager on the server and locate the proxy file inside the web application. Now right-click the file and request it’s properties. Open the “File Security” tab and click the “Authentication and access control” Edit button. Just check the checkbox on the top to enable the anonymous access.
That’s it, save the settings and reset IIS. Now we only have to point the RSS web part to the ashx http location, and the feed will be downloaded!