SP 2007 to SP 2010 Migration #2 – Custom http handlers

Problem

Custom ASP.Net http handlers do not work in SharePoint 2010 after migration from 2007.

Premises

There are several ways one can write a custom http handler for use within a sharepoint environment.

Create .ashx file and a corresponding code behind .cs code and place it in _layouts folder. However that would not work if you dont want to expose the _layouts or you want to use a custom url mapping too (eg MyCustomHttpHandler.logon instead of MyCustomHttpHandler.ashx). So an alternative way is to create a .cs (that implements IHttpHandler) and a custom url mapping and place it in the <httpHandlers> section in web.config.

Solution

  1. Open IIS 7 and select the SharePoint site
  2. Open Handler mappings
  3. Add Managed Handler
  4. Provide a name and use the same type as used in the web.config section for httpHandlers
  5. Restart IIS

Now the http handler will work.

Reason

When migrating to 2010, one of the changes was using the Integrated app pool instead of classic app pool. If your new site is using Integrated app pool, IIS 7 expects the handlers to be in a different section – specifically <system.webServer><handlers> section. In classic mode, the handlers are used from <system.web><httpHandlers> section.

Adding the custom http handlers within this section allowed IIS 7 to map the handler to the code.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: