ThreadAbortException on Redirect

Z

Zeba

Hi !

I am using a httphandler to perform some url rewriting in my
application. My web.config contains the following entry to direct all
urls containing /App/*.ashx to my class AppHandler.cs in namespace
mySite.Web

<httpHandlers>
<add verb="*" path="App/*.ashx"
type="mySite.Web.AppHandler, App_Code"/>
</httpHandlers>

It works perfectly fine in Firefox, but the redirection does not take
place in IE. In IE I get a 404 error - Page cannot be found, and the
address bar contains :

http://localhost/mySite/App/?keyword=mySearchWord

The Debug output showed :

A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException' occurred
in mscorlib.dll but was not handled in user code

Based on some suggestions I found in some forums I tried modifying my
Redirect statement in the AppHandler from

context.Response.Redirect(redirectionURL);

to

context.Response.Redirect(redirectionURL,true);

in which case I get the same Debug ouput. If I also enclose this
statement inside a try catch, I get the following Debug output

A first chance exception of type
'System.Threading.ThreadAbortException' occurred in mscorlib.dll
A first chance exception of type
'System.Threading.ThreadAbortException' occurred in
App_Code.k5agqn3f.dll
An exception of type 'System.Threading.ThreadAbortException' occurred
in App_Code.k5agqn3f.dll but was not handled in user code
The thread 0xec0 has exited with code 0 (0x0).

( App_Code is the assembly name for my AppHandler )

WHAT IS HAPPENING ??!! Please help !
 
G

George Ter-Saakov

I believe that is how Response.Redirect works.

It adds redirect header information to response and need to end processing.
So it throws an exception to unwind everything. Cause it does not know where
in your code you used id.

I would think Response.End does same thing.

George.
 
Z

Zeba

Okayy... thanks..my error had been caused by something else
altogether...a missing cookie.
Now the site is deployed and Redirect still throws the exceptions,
like u said..
 

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