Quiz Answer: Watch out for the Eeeevil Thread.Abort.
Yesterday I posted a little
with an example of an
HttpHandler implemented as an
Brad Wilson obviously knew
the answer, but only gave a hint for others to elaborate on. BigJimSlade
(no link given) expanded on the answer.
BigJim, I have a GMail account
for you if you want one.
HttpResponse.Redirect(string url) actually calls an overload
HttpResponse.Redirect(string url, bool endResponse) with
set to true. If
endResponse is set to true,
will make a call to
That method in turn calls
Thread.CurrentThread.Abort(). Oh the
its ugly head.
So as you see, the code sample will ALWAYS redirect to /default.aspx
HandleRedirect method throws a
every time. To fix this, I merely need to change the
method to call
The fact that this week seems to be “
Thread.Abort Week” isn’t why I
posted this quiz. I ran into this problem the other day in my
carelessness. It’s a result of my old ASP 3.0 habits resurfacing after
years of suppressing them. It took me a few minutes to realize why my
code never made it to special.aspx.