Click here to check my latest exciting videos on youtube
Search Mallstuffs

Flag Counter
Spirituality, Knowledge and Entertainment

Locations of visitors to this page

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
Uploading file asynchronously using Ajax AsyncFileUpload control
JQuery FAQ and Jquery Effects
What is Silverlight,its features and how it works
Silverlight New features & system requirement
Show Update Progress Animation-Ajax
Working with canvas in silverlight
Ways of implementing AJAX
Calling silverlight methods from javascript
Working with server controls and HMTL controls
Increase performance of your website using caching

Post Comment