我们为SharePoint部署构建了一个简单的IHttpModule,它使用以下基础捕获异常并通过电子邮件向开发人员发送内容:
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
}
在尝试以“正确”的方式部署它时,我们使用 SPWebConfigModification 将类型添加到< httpModules > web.config的节点。
我们的问题是第一个< add />在< htpModules >是 Microsoft.SharePoint.ApplicationRuntime.SPRequestModule ,它捕获并清除所有异常,阻止我们的处理程序处理错误。我们已通过手动修改web.config以在 SPRequestModule 之前放置我们的处理程序并使用Reflector查看 SPRequestModule 的操作来验证此行为。
将此条目录入web.config并在 SPRequestModule 之前出现的“最佳做法”是什么?
答案 0 :(得分:0)
你是否尝试过在Global.asax中挂钩Application_Error事件,你应该能够在Module中做你想做的事。