ASP .NET & System.Threading.ThreadAbortException Error

While doing some work today I started to run into a ThreadAbortException error. While debugging it spit back this error:

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

I was really confused because everything seemed to be working just fine, then I found this forum thread. Turns out there are several causes for this error, but mine was caused by doing a Response.Redirect(); from within a Try-Catch statement. Apparently ASP .NET does not like that.


In a try-catch statement, use a boolean variable to mark weather or not to Redirect (or some other variable to accomplish your logic) and preform the Response.Redirect(); outside of your Try Catch. On a side note, I’ve successfully been able to Redirect from inside the Catch {} aspect, just not the try {}.


Here is the link to the forums that I found my answer:

5 thoughts on “ASP .NET & System.Threading.ThreadAbortException Error

  1. Hey Justin,

    Saved me getting into a vicious circle. I have finished working on my website and it is getting ready to go to production and guess what I discover this issue. My problem is exactly as yours redirecting from inside a try block. Thanks a ton.



  2. Thanx it helped me too


  3. thank u u helped me also


  4. thanks By Justin Carmony . good nice post.


  5. Thank you. I was scratching my head at this error!


Leave a Reply to chandu Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close