I create my httpmodule base on this article Global Exception Handling in SharePoint but he didn't said how can i use this in sharepoint 2010 and where should i put this and make it functional.
as far as i know, i must put the "add" tag in "module" or "httpmodule" section into web.config file and add the dll file into GAC or "bin" folder to make it work, am i right?

2 Answers 2


Indeed, that should be all you need to do to get the module to work.

I would wrap this up though in a solution that deploys the DLL to the GAC, and a Farm-scoped Feature with Receiver Code that injects the required lines into web.config using SPWebConfigModification.

You could do it manually, but if you have multiple web front ends, this method will ensure the are all synchronised and have the exact same changes made to all of them.

Plus, uninstallation is easier (you just need deactivation code to remove the lines from webconfig, again using SPWebConfigModification). And when you retract the solution, it'll remove the DLL from the GAC for you. Again, all of this is synchronised across all your web front ends.

  • 1
    thanks for reply James. if you can tell me where or which template of visual studio should i use?, that gonna be solves my problem. Jul 18, 2011 at 4:49
  • 1
    when i do it manually i get this error: "The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)". do you know what is all about? Jul 18, 2011 at 5:11
  • Let's see your add tag you put into web.config.
    – James Love
    Jul 18, 2011 at 7:13
  • You'll need an "Empty SharePoint Solution" if you're using Visual Studio 2010. Add a reference to your DLL in your solution and set it to GAC deployment. Add a Feature, then a Feature Receiver, uncomment FeatureActivating, then find some code on Google/Bing which shows you how to use SPWebConfigModification.
    – James Love
    Jul 18, 2011 at 7:13
  • 1
    i create a class library with vs 2010 and .net 3.5 with the strong name key file and my namespace and assembly name is "OnlineUsersHTTPModule" and my class name is "OnlineUsersModule" and i added the output dll to GAC and also add this tag to web.config in modules section(because of integrated mode): <add name="Test" type="OnlineUsersHTTPModule, Version=, Culture=neutral, PublicKeyToken=78aac1459052cd0a" preCondition="integratedMode" /> Jul 19, 2011 at 4:12

You may want to consider an alternative to the blog poist your referenced that does not require a custom HTTP module. SharePoint 2010 allows you to register your own custom error page without the need for a custom HTTP module.


  • thanks for reply. but actually i need to use something like global.asax file and it's events like "Session_Start". that's why i have to use httpmodule. Jul 18, 2011 at 4:20
  • That does NOT work for 404s, but ONLY for the internal SharePoint errormessages
    – Ole Albers
    Nov 21, 2011 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.