Thursday, March 22, 2012

Thread Error

I get this thread error in my custom error log. It occurs on a
Response.Redirect statement. The odd thing it does not seem to affect
the functionality of the application at all. What causes this error:

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 contact911.planpayment.ProcessOrder() in C:\Inetpub\wwwroot\dirname\payment.aspx.vb:line 344.net pages run as programs, since you redirected the user, the program stops running.
This doesn't always happen though, its actually rare (it happens on two of my pages out of about 50). Why would the page still be running when the redirect occurs?
well it's not that the others r still running, just that exception while closing them wasnt thrown, lookig at it again, it seems like the error is when the thread tries to abort, but is already aborting.. perhaps something to do wih how quickly things are executed.

there is likely nothing you can do about it though, the exception comes from within the redirect statement, not your code.

The other possibility i can think of is perhaps if you have code in the unload event of those two forms.. but the strack trace indicates that it comes from the redirect statement.. so i guess that possibility is out.
I'm not that concern that the error is thrown, I'm just worried if the functionality will be interrupted. There is a lot of code in the Submit_Click method, then a lot of code in the Page_Load method of the page it goes too - maybe thats why it doesn't finish smoothly? So far all the functionality executes properly and completely, even when the error is thrown, but I'd still like to know why its doing it.
I did alot of searching, and it seems this is normal behavior.. all the typical asp ending functions will throw an exception most of the time.. which has to be a design flaw on microsofts behalf..

the way to fix it, tells microsoft is using the overload .Redirect("url", False)
and instead of response.end (for future reference) use HttpContext.Current.ApplicationInstance.CompleteRequest

i found this info at http://support.microsoft.com/default.aspx?scid=KB;EN-US;312629

0 comments:

Post a Comment