【发布时间】:2012-02-28 18:28:50
【问题描述】:
我编写了以下 HTTP 模块来捕获所有异常:
namespace Code.CapEx.Web.Framework.Http.Modules
{
public class ExceptionHandlingModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.Error += OnError;
}
private static void OnError(object sender, EventArgs e)
{
var exc = HttpContext.Current.Server.GetLastError();
ProcessException(exc.InnerException);
}
private static void ProcessException(Exception exception)
{
HttpContext.Current.Items["LastError"] = exception;
EntLogger.Instance.Error(exception);
if (exception is PermissionsException)
{
HttpContext.Current.Response.Redirect("~/_layouts/MyProject/NotAuthorized.aspx");
}
else
{
HttpContext.Current.Server.Transfer("~/_layouts/MyProject/Error.aspx");
}
}
}
}
它在我的开发机器上完美运行(没有共享点)并且真正捕获所有异常。
但在 QA 机器上,此站点在 sharepoint 2010 文件夹下工作,根本不会捕获异常!
问题的根源是什么? (我没有忘记在 web.config 中注册 http 模块;))
【问题讨论】:
-
可能捕获到异常,但不执行重定向,用户可以看到异常详情。
标签: c# .net sharepoint exception module