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?