Global.asax
protected void Application_Error(Object sender, EventArgs e)
{
//在出现未处理的错误时运行的代码
Exception objErr = Server.GetLastError().GetBaseException();
//清除前一个异常
Server.ClearError();
System.Web.HttpContext.Current.Response.Redirect("/Logout.aspx");

为什么连在html源文件里面 一个JS掉不到,或者调的一张图片部存在都会执行Application_Error 
怎么会这么敏感

解决方案 »

  1.   

    没什么错误信息啊。我就是在
    protected void Application_Error(Object sender, EventArgs e)
    {}
    里面写 错误的跳转页面啊 , HTML 里面有图片 调不到 不存在,也会执行这个事件这么敏感 ,有谁遇到过,或者你们试试看。。
      

  2.   


    把错误贴出来,要不把你调用图片的代码贴出来。
    不然没有人知道是什么原因。
    如果单纯html调用一张图片,没有这张图片,不会报错的。那个报错,是因为你代码的原因。
      

  3.   

    只在后台出错才会走到Application_Error的。你应该把错误堆栈打出来检查下。
      

  4.   

    {System.Web.HttpException: 文件不存在。
       在 System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context)
       在 System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
       在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)}
      

  5.   

    比如 页面上 <img src="images/right_now_login.gif" /> 有 right_now_login.gif 这张图片。
    我在
    protected void Application_Error(Object sender, EventArgs e)
    ●{}
    做了个断点 调试 我把图片 换成right_now_login11111.gif  它每次都要触发这个事件。