2011-01-21 65 views

回答

1

查看Application_Error事件,可以将其放入Global.asax文件(更多信息herehere)。
基本上,每当应用程序代码中存在未处理的异常时,都会调用该事件 - 这是另一个不处理您无法管理的异常的理由。

1

不要写你自己的,但使用现有的像log4netNLog

2

的Global.asax:

<%@ Application Inherits="MyProj.Global" %> 

的Global.asax.cs:

namespace MyProj 
{ 
    public class Global : HttpApplication 
    { 
     protected virtual void Application_Error(object sender, EventArgs e) 
     { 
      Exception ex = Server.GetLastError().GetBaseException(); 
     } 
    } 
} 
相关问题