Help ThreadAbortException for Response.Redirect!

  • Thread starter Thread starter VB Programmer
  • Start date Start date
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?
 
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
 
Back
Top