Response.Redirect generates and Exception

G

Guest

Hi,
I have a try block in which I execute a Page.Response.Redirect("myPage.aspx");

This statement always generates the exception: "Thread was being aborted"
and the execution continues in the catch block.
Is there a way to execute Page.Response.Redirect without generating this
exception?
Or if not, is there at least a way to ignore this exception in the code?

Thank you.
 
K

Karl Seguin

You can do Page.Response.Redirect("myPage.aspx", false);

this will tell it to continue processing the page and THEN redirect....thus
not causing the thread to be aborted....personally, I don't care much for
this solution (not that it's overly bad). What's the deal with the
exception being generated? You can ignore it by swallowing it:

try{
Response.Redirect("blah.aspx");
}catch (ThreadAbortException ex){ }


Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top