捕捉错误我这是指用于处理错误在我Global.aspx如下:在Global.asax中
void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
if (exception != null)
{
//Log
if (HttpContext.Current.Server != null)
{
HttpContext.Current.Server.Transfer("/siteerror.aspx");
}
}
}
这适用于大多数情况,但有时不会惹上Server.Transfer的。由于某种原因HttpContext.Current.Server为空。我想出了发生这种情况的原因:在用户控件和业务逻辑类中发生错误时。我在这里错过了什么吗?
谢谢
任何理由不使用'Response.Redirect'宁可? – leppie 2012-04-08 09:41:56
global.asax在哪里? – 2012-04-08 09:42:35
@leppie我没有添加这个,所以不完全确定为什么以前的人选择Server.Transfer,它应该没有区别,但它应该吗? – Peuge 2012-04-08 09:53:50