韩言福地

只有想不到的,没有办不到的。 - HY Auspicious Place

« 使Repeater在数据为空时显示提示信息MSSQL的datediff函数 »

在Global中Application_Error事件处理错误信息

在Global中Application_Error事件处理错误信息
在Global中 
protected void Application_Error(Object sender, EventArgs e)
  {
   Exception objErr = Server.GetLastError().GetBaseException();
   string error = "发生异常页: " + Request.Url.ToString() + "<br>";
   error += "异常信息: " + objErr.Message + "<br>";
   Server.ClearError();
   Application["error"] = error;
   Response.Redirect("~/ErrorPage/MyErrorPage.aspx");
  }
Web.config中
    <customErrors mode="On"/>
    <authentication mode="Windows"/>
注:(Response.Redirect语句在任何情况下都会产生ThreadAbortException异常,但不捕获该异常并不会引起程序中止。如果不设置mode="On",在Application_Error事件会捕获它的异常,中并又回到该过程本身,所以会引起死循环。)

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Copyright 2007-2010 www.yinrg.com(HY Auspicious Place) . 湘ICP备06007796号.