2

这个例子对我有用,我试过 Response.write 但我什么也没得到。这是示例(是否也可能出现一个弹出窗口告诉错误详细信息“)

protected void Application_Error(object sender, EventArgs e)
{
      // At this point we have information about the error
      HttpContext ctx = HttpContext.Current;

      Exception exception = ctx.Server.GetLastError ();

      string errorInfo = 
         "<br>Offending URL: " + ctx.Request.Url.ToString () +
         "<br>Source: " + exception.Source + 
         "<br>Message: " + exception.Message +
         "<br>Stack trace: " + exception.StackTrace;

      ctx.Response.Write (errorInfo);


      ctx.Server.ClearError ();
    }
4

1 回答 1

2

在 Global.asax 中的应用程序中遇到未处理的异常时触发的事件的方法签名是:

void Application_Error(object sender, EventArgs e)
{
     // your code...
}
于 2013-08-18T21:18:56.943 回答