Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
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. –  Jalali Shakib Jul 18 '11 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? –  Jalali Shakib Jul 18 '11 at 5:11
    
Let's see your add tag you put into web.config. –  James Love Jul 18 '11 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 '11 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=1.0.0.0, Culture=neutral, PublicKeyToken=78aac1459052cd0a" preCondition="integratedMode" /> –  Jalali Shakib Jul 19 '11 at 4:12
show 2 more comments

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.

http://todd-carter.com/post/2010/04/07/An-Expected-Error-Has-Occurred.aspx

share|improve this answer
    
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. –  Jalali Shakib Jul 18 '11 at 4:20
    
That does NOT work for 404s, but ONLY for the internal SharePoint errormessages –  Ole Albers Nov 21 '11 at 14:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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