Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
17 Dec 2020 21:59:00,950 [50928] ERROR ErrorLog - Thread was being aborted.
17 Dec 2020 21:59:00,950 [50928] ERROR ErrorLog - 
17 Dec 2020 21:59:01,295 [50928] ERROR ErrorLog -    at System.Threading.Thread.AbortInternal()
   at System.Threading.Thread.Abort(Object stateInfo)
   at System.Web.HttpResponse.AbortCurrentThread()
   at System.Web.HttpResponse.End()
   at System.Web.HttpServerUtility.Transfer(String path, Boolean preserveForm)
   at System.Web.HttpServerUtility.Transfer(String path)
   at customerdetails.btncheckout_click(Object sender, EventArgs e) in e:\..........\customerdetails.aspx.cs:line 1781


What I have tried:

if (done == 0)
                    {

                    }
                    else
                    {
                        details.Visible = true;
                        bindccdetails();
                        UpdatePanel2.Update();

                        Server.Transfer("~/ccav.aspx");  // i got error here
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Your Cart List Is Empty')", true);
                }
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
            logger.Error(ex.InnerException);
            logger.Error(ex.StackTrace);
        }
    }
Posted
Updated 17-Dec-20 20:25pm
v2

1 solution

As mentioned in Microsoft documentation: Exception when you use Server.Transfer - ASP.NET | Microsoft Docs[^]

Quote:
When you call Server.Transfer, ASP.NET internally calls the Server.Execute method to transfer the control, and calls the Response.End method to end the processing of the current page. Response.End ends the page execution and calls the Thread.Abort method. The Thread.Abort method causes the ThreadAbortException error message to appear.

To work around this problem, use Server.Execute instead of Server.Transfer in the ProcessRequest method of HTTPHandler. The modified ProcessRequest method is as follows:
C#
public void ProcessRequest(HttpContext context)
{
   try
   {
      context.Server.Execute("WebForm1.aspx");
   }
   catch(System.Exception e)
   {
      context.Response.Write(e.StackTrace);
      context.Response.Write(e.ToString());
   }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900