Click here to check my latest exciting videos on youtube

Search Mallstuffs

Flag Counter
Spirituality, Knowledge and Entertainment

Latest Articles

Move to top
Response.Redirect throws _Thread was being aborted_
Posted By Sarin on Nov 18, 2012     RSS Feeds     Latest Hinduism news

While working on a project, I got this error on doing a Response.Redirect operation. When I searched for reasons behind this error, I got the following results:
  1)    Server.Transfer and Response.Redirect methods redirect users to another page and internally call Response.End method.  Response.End immediately ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline.  
    2)    By design, .Net automatically throws a ThreadAbortException  on a Response.Redirect operation. To avoid this, set the 2nd parameter (EndResponse ) of redirect operation to false. Since we are bypassing end response, ThreadAbortException method will not be called.
  3)    Move Response.Redirect method outside the try/catch block. If there is a need to handle exceptions then first catch ThreadAbortException exception and do nothing in that catch block. Put your other exceptions blocks below ThreadAbortException block.
    // Do stuff.
    // Do nothing. ASP.NET is redirecting.
catch(Exception ex)
    // Log other exceptions.
  4)    Write your own custom redirect function like the one shown below
               Private void Redirect(string url, bool hasErrored)
                If (hasErrored)
                  HttpContext.Current.Response.Redirect(url, False)
            Else  {
                HttpContext.Current.Response.Redirect(url, False)
  5)    None of the above solutions worked for me. In my case, error was due to wrong page path. I was redirecting to the page above the root directory .i.e. I added extra.. In the path of redirect method. Using ~ sign for root directory worked. Make sure you are redirecting the page to the valid location.
Note: Images used on this website are either a production of Bhaktivedanta Book Trust(, Iskcon Foundation or were found in google search under "Free to use and share". If any of the images presented here violates copyright issues or infringes anyone copyright or are not under "Fair use", then please bring it to our notice. Read Disclaimer for more.

Share this to your friends. One of your friend is waiting for your share.
Related Articles
How Silverlight works internally
Silverlight New features & system requirement
Database cannot be opened due to inaccessible files or insufficient memory or disk space
Working with forms-Jquery form selector
What is Silverlight,its features and how it works
Response.Redirect throws _Thread was being aborted_
Jquery features, Advantages and disadvantages
How AJAX Works, advantages and disadvantages
Calling silverlight methods from javascript
Show Update Progress Animation-Ajax

Post Comment

Software developer by profession,
Poet by hobby,
Blogger by Passion
Birth Place: Munger(Top Yoga city)
Residence: Mumbai, Maharashtra
Prof exp: 8 years

Read More about me

Read my daily what'sapp quotes
Most Viewed Articles

Latest Spiritual Videos

Latest News

Latest Social Post
Latest WhatsApp Quotes