Thread aborted using Response.Redirect in ASP.Net

by demtron on Monday, February 02, 2009 08:13 AM

I added a Response.Redirect to a .Net Web page and began receiving a "Thread was being aborted" error on a line of code that executed Response.Redirect.  Without really considering it, this error made sense based on the place where I added the code.

Response.Redirect will call Response.End by design.  However, this will also raise a ThreadAbortException.  In my case, it was because the redirect line was within a try...catch block.  I found two ways to handle this:

  1. Change Response.Redirect(<URL>) to Response.Redirect(<URL>, false)
  2. Move the line to outside the try...catch block
I ended up using method #2, but both options worked for me.

Comments

Comments are closed

Powered by BlogEngine.NET 1.5.1.18
Theme by Mads Kristensen · Adapted by Demtron

Bookmark and Share

Calendar

<<  April 2024  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar
Log in

Milwaukee SEO Company

Milwaukee Access Programmer/Developer

Milwaukee Website Designer and Developer



Marketing / SEO

Blog Directory
blogarama - the blog directory
TopOfBlogs
Milwaukee area SEO, SEM, ASP.Net