locked
ThreadAbortException RRS feed

  • Question

  • User895620303 posted
    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
    AppHandler

    <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 !

    Thursday, March 29, 2007 2:10 AM

Answers

  • User1109032460 posted

    Don't worry about the ThreadAbortException. This is simply a result of the fact that the call to Response.Redirect calls (via the End method) Thread.Abort() on the current thread. This is perfectly fine.

    What's obviously not fine is the url that you are generating (.../App/?keyword=mySearchWord) , which is clearly missing the something.ashx that is necessary for it to be handled by the specified handler. Can you therefore please post your code that prepares the rewritten URL, and also indicate where that code is being called.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 29, 2007 5:20 AM

All replies

  • User1109032460 posted

    Don't worry about the ThreadAbortException. This is simply a result of the fact that the call to Response.Redirect calls (via the End method) Thread.Abort() on the current thread. This is perfectly fine.

    What's obviously not fine is the url that you are generating (.../App/?keyword=mySearchWord) , which is clearly missing the something.ashx that is necessary for it to be handled by the specified handler. Can you therefore please post your code that prepares the rewritten URL, and also indicate where that code is being called.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 29, 2007 5:20 AM
  • User895620303 posted

    You're right that was the problem .. I had run a page to save configurations in a cookie, only from mozilla. Based on the configuration name i was reading the file mapping from a database.

    I hadn't run the configurations page in IE. As a result while creating the redirectionURL string the file path was always null.

    Thanks ! 

     

    Thursday, March 29, 2007 8:41 AM