Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        '在出现未处理的错误时运行的代码
        'If (Server.GetLastError().Message.Contains("HttpUnhandledException")) Then
        '    System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "abc.txt", "上传文件过大!")
        'End If
        
        Dim objErr As Exception = Server.GetLastError().GetBaseException()
        Dim [error] As String = "发生异常页: " & Request.Url.ToString() & ""
        [error] += "<br/>异常信息: " + objErr.Message & ""
        Server.ClearError()
        Application("error") = [error]
        Response.Redirect("errorpage.aspx")    End Sub可以扑捉到错误,但是就是最后的Response.Redirect("errorpage.aspx")跳转无效, 出错后在火狐下显示 连接被重置 ,载入页面时到服务器的连接被重置。是什么原因 ? 

解决方案 »

  1.   

    "载入页面时到服务器的连接被重置"errorpage.aspx跟global同一目录吗?
    直接打开errorpage.aspx是否有错导致循环重定向。
    是否重写beginRequest了事件?
      

  2.   

    errorpage.aspx跟global是在同一目录errorpage目前是一个空页面,没有加载其他代码Application_Error 加了断点看到只运行了一次,所以没有死循环的可能
      

  3.   

    Web.config 加入 
    <customErrors mode="On" defaultRedirect="GenericErrorPage.htm" > </customErrors> 或使用
    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.aspx");
    }
    //ErrorPage.aspx 
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Text = Application["error"].ToString();
    }
    FORM认证
      

  4.   

    本地测试成功,貌似火狐对Response.Redirect的兼容有问题。
    改为 Response.Redirect("~/errorpage.aspx") 本地测试成功,
    今天晚上挂网上试试
      

  5.   

    用Response.Redirect("errorpage.aspx",true);或者
    Server.Transfer("errorpage.aspx");
      

  6.   

     可为目标位置指定一个绝对 URL(例如 http://www.contoso.com/default.aspx)或相对 URL(例如 default.aspx),但有些浏览器可能不接受相对 URL。最好使用firebug来查看http头