views:

207

answers:

1

We've built a simple IHttpModule for our SharePoint deployment that catches exceptions and emails the developers the contents using the following foundation:

public class ExceptionReporter : IHttpModule
{
    //snip

    public void Init(HttpApplication context)
    {
        context.Error += new EventHandler(context_Error);
    }

    void context_Error(object sender, EventArgs e)
    {
        //Do stuff here
    }

    //snip
}

In trying to deploy it the "proper" way, we're using a SPWebConfigModification to add the type to the <httpModules> node of web.config.

Our problem is that the first <add /> in <htpModules> is Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, which catches and clears all exceptions, preventing our handler from working with the error. We've verified this behavior both by manually modifying the web.config to put our handler before SPRequestModule and using Reflector to view the actions of the SPRequestModule.

What is the "best practice" way to get this entry into web.config and appear before SPRequestModule?

A: 

Did you Tried to hook the Application_Error event int he Global.asax, You should be able to do what you are trying to do in Module.

Kusek
No, we haven't tried that yet since I've seen references to that not being a best practice. How would you suggest changing that file as part of a WSP deploy, since it's underneath inetpub instead of in the 12 hive? Related SO question: http://stackoverflow.com/questions/122205/how-can-you-hook-a-sharepoint-2007-feature-into-the-applicationstart-of-a-site
boflynn