zoukankan      html  css  js  c++  java
  • response.redirect 正在中止线程

    问题描述:正在中止线程
    问题原因:
    Response.End 方法终止页的执行,并将此执行切换到应用程序的事件管线中的 Application_EndRequest 事件。不执行 Response.End 后面的代码行。
    解决方案
    要解决此问题,请使用下列方法之一: ? 对于 Response.End,调用 HttpContext.Current.ApplicationInstance.CompleteRequest 方法而不是 Response.End

    以跳过 Application_EndRequest 事件的代码执行。 
    ? 对于 Response.Redirect,请使用重载 Response.Redirect(String url, bool endResponse),该重载对 endResponse 参数传递 false 以取消对

    Response.End 的内部调用。例如: Response.Redirect ("nextpage.aspx", false);如果使用此替代方法,将执行 Response.Redirect 后面的代码。 
    ? 对于 Server.Transfer,请改用 Server.Execute 方法。 

    protected void Redirect(string url)
    {
        this.isRedirecting = true;
    
        Response.Redirect(url, false);
    
        if (Context.ApplicationInstance != null)
            Context.ApplicationInstance.CompleteRequest();
    }

    Response.Redirect("/InvalidAccess.aspx", False)
    HttpContext.Current.ApplicationInstance.CompleteRequest()


    Response.Redirect("Default.aspx", false);
    return;


    https://stackoverflow.com/questions/13125361/asp-net-4-5-async-await-and-response-redirect

  • 相关阅读:
    UVA 10305 Ordering Tasks(拓扑排序)
    UVA 1152 4 Values whose Sum is 0(中途相遇法)
    UVA 1103 Ancient Messages
    HDU 2141 Can you find it?
    POJ 2456 Aggressive cows(二分+贪心)
    Tallest Cow【模拟】
    Tallest Cow【模拟】
    激光炸弹【模拟】
    激光炸弹【模拟】
    激光炸弹【模拟】
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/11689829.html
Copyright © 2011-2022 走看看