ASP.Net Response.Redirect not working in Application_Error?

后端 未结 5 1928
萌比男神i
萌比男神i 2021-01-04 03:52

I don\'t know why the Response.Redirect not working properly when I deploy my code to IIS7? The white/yellow error page always get displayed instead of my Errors.aspx. But w

相关标签:
5条回答
  • 2021-01-04 04:26

    Try to turn off the CustomError in web.config. It will give you more specific about the error details. Maybe it doesn't the error from Response.Redirect.

    0 讨论(0)
  • 2021-01-04 04:29
    protected void Application_Error(object sender, EventArgs e)
    {            
         Exception objErr = Server.GetLastError().InnerException;
        //Logging.WriteToErrorLog("Error Caught in Application_Error event", objErr);
       HttpContext.Current.Server.ClearError();
       HttpContext.Current.Application.Add("test", objErr);
       HttpContext.Current.Response.Redirect("~/Home/Index");
       return;
    }
    
    0 讨论(0)
  • 2021-01-04 04:41
    HttpContext.Current.Server.ClearError();
    HttpContext.Current.ClearError();
    ====================================================================
    Redirect to NEW VIRTUAL! directory (Error)
    HttpContext.Current.Response.Redirect([http://localhost:8990/Error/ErrorPageServer.aspx]);
    
    0 讨论(0)
  • 2021-01-04 04:45

    For me the below code worked.

    HttpContext.Current.Server.ClearError();
    HttpContext.Current.Response.Redirect("~/ErrorPage.aspx");
    
    0 讨论(0)
  • 2021-01-04 04:48

    I had the same problem and solved it with:

    HttpContext.Current.ClearError();             
    Response.Redirect("~/Error.aspx", false);
    return;
    
    0 讨论(0)
提交回复
热议问题