0
我已經寫了下面的HTTP模塊捕獲所有異常:SharePoint 2010中,異常處理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");
}
}
}
}
它完美我的開發機器上(沒有的SharePoint),真正捕獲所有異常。
但在質量保證機器上,本站在sharepoint 2010文件夾下工作,異常不會被捕獲!
什麼是問題來源? (我沒有忘記在web.config中註冊http模塊;))
可能發生異常,但不執行重定向,用戶可以看到異常詳細信息。 – Ruslan 2012-02-28 18:31:00