Wednesday, September 20, 2006

Ajax RSS Web Part for Sharepoint

Ajax is a relatively new way of programming web pages that allows a the web browser to interact with a web server without requiring entire page loads or form posts. The most common example of a web page that uses Ajax is Google Maps, where you will notice that the web page manages to keep feeding you new data without ever actually having to load a new page.

I've spent the last 2 years programming a number of web parts for Microsoft Sharepoint Portal Server using Visual Studio.NET. A few weeks ago, I finally found the time to test out the Ajax.NET library and was instantly sold on using Ajax in all of my new web part projects.

Like many companies, our Sharepoint home page is designed to be a central dashboard (meant to be left open all day) which allows users to quickly see information from all over the company. Currently, our Sharepoint home page is configured to auto automatically reload every few minutes to keep the data fresh. With Ajax, I'll be able to update the data in the web parts themselves instead of reloading the whole page. The result has a more polished feel than a clumsy page refresh.

The first step for the project was to create an RSS news reader to replace the Microsoft XML reader that was currently being used. You'll find details about this Ajax RSS News Reader below, installation instructions and downloads for the web part in either binary or source format.

First, the obligatory screenshots:

Screenshot 1:
Screenshot 2:

Screenshot showing settings window:

Advantages/Features of this web part
  • Web part automatically updates itself as long as the web page is open, ensuring the latest RSS feed data.
  • News feeds are cached on the Sharepoint server so subsequent requests are answered from cache as long as the data is current. The default refresh time is 5 minutes, but that may be overriden by a TTL within the feed itself, or in the web part settings. To see the active TTL, look at the tooltip for the web part by mousing-over the web part title.
  • The web part automatically sets the title name according to the name on the RSS Feed.
  • Feed logo is optionally displayed as a watermark in the background so it doesn't take up space.
  • If only the title is displayed, the tooltip will show the summary of the article if you mouseover the link.
  • The web part uses the very hip Scriptaculous Highlight Effect to show when the data has been refreshed.
How to install

1. Locate the directory where sharepoint portal server is installed (i.e. C:\Inetpub\wwwroot). You should see a web.config file in this location.

2. Edit the web.config file:
2.1. In the <SafeControls> section, add the following line:

<SafeControl Assembly="AjaxRSS, Version=, Culture=neutral, PublicKeyToken=464e1ec8837b09fa" Namespace="AjaxRSS" Typename="*" Safe="True"> </SafeControl>

2.2. (Updated) Add the following right above the last </configuration> tag:

<location path="ajaxpro">
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro, Version=, Culture=neutral, PublicKeyToken=4735ae9824c7d3ec"/>

2.3 Change the trust level to "Full".

<trust level="Full" originurl="">

2.4 Save the web.config file.

3. Create a bin directory in the virtual server root (i.e. C:\Inetpub\wwwroot\bin) and copy the *.DLL files (AjaxPro.dll, AjaxRSS.dll and RSS.dll) into this location.

4. Copy the folder with the javascript files into the wpresources folder (ex: C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\scriptaculous)

5. Add the path (/ajaxpro) to the excluded paths in Sharepoint Central Administration:
5.1 On the server, click on Start...All Programs...Sharepoint Portal Server...Sharepoint Central Administration.
5.2 Click Configure virtual server settings from the Virtual Server List page (this is under the Portal Site and Virtual Server Configuration section)
5.3 Click on the virtual server you will be running the web part on.
5.4 Click on "Define managed paths" (this is in the Virtual Server Management section).
5.5 In the Add a New Path section, type: /ajaxpro
5.6 Change the type to "Excluded Path"
5.7 Click on the OK button.

6. Open a command prompt and run iisreset to restart the web server.

7. Open Internet Explorer and go to the sharepoint site. Import/upload the AjaxRSSReader.dwp file to load the web part on the page.

7. To test, simply assign a RSS feed to the URL settings and set the override to 1 (so it will update every minute).

Ajax.NET code is available here:
Scriptaculous code is available here:
RSS library for .NET is available here:

Please refer to those sites or the source code for any applicable copyright information.

My web part (AjaxRSS.dll) and the source code is licensed under the Creative Commons Attribution 2.5 License. To view a copy of this license, visit or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.


Binary + Source (zip) * last updated 12/22/2006

  • I have tested on a fresh install of Sharepoint Portal Server 2003. The web part has not been tested with Sharepoint 2007.

  • The web part should not be installed in the GAC (Global Assembly Cache) as this will currently break the ajax functionality.

If you use my web part, please add a comment here.


Scott said...

FYI, the directions for adding the verb to the httpHandlers section were incorrect and have been updated. If you previously installed this web part, please update your web.config file.

Scott said...

FYI, I have updated the zip file with the latest version. The new version includes the ability to turn off generating the web part title automatically from the title of the rss feed. This is helpful when the title of an RSS feed is too long. The code also fixed an error where the web part could not be moved between zones or closed.

Robert Fernandez said...

Do you have a version of this code that is for

Happy Wednesday,

Scott said...

No, but if you know VB.NET, it would be easy to cut and paste much of the source code into a new non-Sharepoint project. The code takes advantage of Sharepoint properties, but otherwise is not dependent on Sharepoint.

Jeff said...

Have you tested this on SPS 3.0?