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

<<  January 2025  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar
Log in

Milwaukee SEO Company

Milwaukee Access Programmer/Developer

Milwaukee Website Designer and Developer

Subscribe rss feed!

Marketing / SEO

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