Help ThreadAbortException for Response.Redirect!

V

VB Programmer

I have a default.aspx page that simply does this (in the "Try" block):
Response.Redirect("MyStartPage.aspx")

I keep getting this exception on this line:
"System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
at System.Web.HttpResponse.Redirect(String url)
at MyWeb._default1.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\MyWeb\default.aspx.vb:line 22"

Any ideas?
 
D

David Browne

VB Programmer said:
I have a default.aspx page that simply does this (in the "Try" block):
Response.Redirect("MyStartPage.aspx")

I keep getting this exception on this line:
"System.Threading.ThreadAbortException: Thread was being aborted.
at System.Threading.Thread.AbortInternal()
at System.Threading.Thread.Abort(Object stateInfo)
at System.Web.HttpResponse.End()
at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
at System.Web.HttpResponse.Redirect(String url)
at MyWeb._default1.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\MyWeb\default.aspx.vb:line 22"

Any ideas?

Response.End and Response.Redirect are implemented using
ThreadAbortExceptions. That's how they stop the execution of the page
object. Remember you not only have to exit from Page_Load, you have to stop
any of the other Page methods from firint.

It's just a gotcha that if you catch the exception, it looks like something
is wrong.

David
 

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

Top