HTTP Handlers and SharePoint 2010


Trying to debug an error on a HTTP handler, we got the following error message:

Parser Error Message: Could not create type ‘MyNameSpace.MyClass’.

The HTTP handler directive on the ASHX file looked like this:

<%@ WebHandler Class="MyNameSpace.MyClass" %>

I found the solution for this issue at http://sharepoint.stackexchange.com/questions/19928/sharepoint-2010-and-ashx-handler.

The explanation:

Since we are using SharePoint 2010, the HTTP handler was deployed to the LAYOUTS folder. The trick here is that SharePoint needs to load all its referenced assemblies from the GAC and in this case the assembly was in the GAC but we were not referencing the FQDN of the assembly.

The ASHX file should look like this:

<%@ WebHandler Class="MyNameSpace.MyClass, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7c8e2c3ef53023ee" %>

After updating the ASHX file the error was solved.

See you,

Amadeu.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

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: