Error - mscorlib : Thread was being aborted.

Discussion in 'ASP .Net' started by =?Utf-8?B?VC4=?=, Aug 13, 2005.

  1. I had the following code inside my app
    try
    {
    // Open an ADO.NET db connection
    // Do some db processing here

    Response.Redirect("main.htm");
    }
    catch(Exception e)
    {
    }

    The Response.Redirect("main.htm") state was generating the error 'mscorlib
    : Thread was being aborted'. But when I took that statement out of the
    try..catch block it ran fine. Why does Ressponse.Redirect cause an error
    inside a try..catch statement?

    Thanks in advance
     
    =?Utf-8?B?VC4=?=, Aug 13, 2005
    #1
    1. Advertising

  2. Clarification: Actually its just the try{} block, runs fine in the
    catch(Exceptione) {} block

    "T." wrote:

    > I had the following code inside my app
    > try
    > {
    > // Open an ADO.NET db connection
    > // Do some db processing here
    >
    > Response.Redirect("main.htm");
    > }
    > catch(Exception e)
    > {
    > }
    >
    > The Response.Redirect("main.htm") state was generating the error 'mscorlib
    > : Thread was being aborted'. But when I took that statement out of the
    > try..catch block it ran fine. Why does Ressponse.Redirect cause an error
    > inside a try..catch statement?
    >
    > Thanks in advance
     
    =?Utf-8?B?VC4=?=, Aug 13, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?VC4=?=

    Brock Allen Guest

    A ThreadAbortException is thrown when Redirect is used - it's just how it
    works. Why are you doing a catch(Exception e)? If your code can't "handle"
    every exception, then I'd suggest not having the catch block there. If there's
    a specific exception you know how to deal with, then use the catch (like
    FormatException or SqlException for example). To be notified that there was
    an unhandled exception (one you didn't catch) you should put a Application_Error
    handler in global.asax; this is where your error logging should go.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I had the following code inside my app
    > try
    > {
    > // Open an ADO.NET db connection
    > // Do some db processing here
    > Response.Redirect("main.htm");
    > }
    > catch(Exception e)
    > {
    > }
    > The Response.Redirect("main.htm") state was generating the error
    > 'mscorlib : Thread was being aborted'. But when I took that statement
    > out of the try..catch block it ran fine. Why does Ressponse.Redirect
    > cause an error inside a try..catch statement?
    >
    > Thanks in advance
    >
     
    Brock Allen, Aug 13, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elliot M. Rodriguez
    Replies:
    1
    Views:
    2,978
    Elliot M. Rodriguez
    Jan 22, 2004
  2. Stephen Miller
    Replies:
    3
    Views:
    4,018
    Stephen Miller
    Jul 2, 2004
  3. Johanna
    Replies:
    0
    Views:
    618
    Johanna
    Oct 13, 2004
  4. =?Utf-8?B?Sm9oYW5uYQ==?=
    Replies:
    3
    Views:
    1,991
    =?Utf-8?B?Sm9oYW5uYQ==?=
    Oct 15, 2004
  5. darrel
    Replies:
    5
    Views:
    5,999
    darrel
    Mar 9, 2006
Loading...

Share This Page