c# - What causes 'Thread was being aborted' exception to happen at random and show the HTTP header and partial HTML to the browser? -
what happening @ random instead of html being returned browser expect, looks little this:
thread being aborted.http/1.1 200 ok
(the rest of header)
... (like 1/10th of html)
that's it, literally getting bunch of text in browser window.
it doesn't happen time, randomly. computers... in experience have reason everything, always. what's heck going on here?
i have searched entire solution , found quite few calls response.redirect() seems culprit based on other questions have read...
this , not tell me why happening @ random
...or why giving strange result browser rather normal custom error page have setup. if indeed causing it, have not yet determined. if is, don't think can add 'false' parameter because don't know if kept executing current code.
when call response.end (which called other methods response.redirect , server.transfer) executing thread aborted , threadabortexception thrown (aborting threads not exceptional in asp.net). can catch exception rethrown in catch
handler. sets apart other exception types makes sense because should not able stop thread aborting , in process clean stack executing blocks.
perhaps have exception handling logic response.end
called inside try
block , unexpected output produced in catch
block?
something (probably more convoluted , hard track in "mature" code base):
void handlerequest() { try { response.redirect(...); } catch (exception ex) { response.write(...); } }
if response.redirect
ends response.end
threadabortexception
thrown , response.write
execute adding text response.
Comments
Post a Comment