2.0: unexpected exception "Thread was being aborted"

Discussion in 'ASP .Net' started by R.A.M., May 18, 2006.

  1. R.A.M.

    R.A.M. Guest

    Hello,
    Could you help me plase?
    I have an ASP.NET page with "Search" button; when button is clicked
    Search_Click is called; here's the code:

    protected void Search_Click(object sender, EventArgs e)
    {
    Debug.WriteLine("WWWPage.Search_Click()");
    ...
    try
    {
    Response.Redirect("Searched.aspx");
    }
    catch (Exception ex)
    {
    Debug.WriteLine(
    "WWWPage.Search_Click(): exception: " +
    ex.Message);
    }
    }

    Unfortunatelly Redirect does not work. Here what I found in Output
    window:

    WWWPage.Search_Click()
    A first chance exception of type
    'System.Threading.ThreadAbortException' occurred in mscorlib.dll
    WWWPage.Search_Click(): exception: Thread was being aborted.
    A first chance exception of type
    'System.Threading.ThreadAbortException' occurred in
    App_Web_2xx5zf8y.dll
    An exception of type 'System.Threading.ThreadAbortException' occurred
    in App_Web_2xx5zf8y.dll but was not handled in user code

    Could you explain me please what is going on and how to correct the
    problem? My .NET Framework setup was successful, I use Framework a few
    months and there was no such problems.
    Thank you very much.
    /RAM/
    R.A.M., May 18, 2006
    #1
    1. Advertising

  2. R.A.M.

    Ray Booysen Guest

    Try:

    Response.redirect("Searched.aspx", true);

    and take it out of the try catch.

    R.A.M. wrote:
    > Hello,
    > Could you help me plase?
    > I have an ASP.NET page with "Search" button; when button is clicked
    > Search_Click is called; here's the code:
    >
    > protected void Search_Click(object sender, EventArgs e)
    > {
    > Debug.WriteLine("WWWPage.Search_Click()");
    > ...
    > try
    > {
    > Response.Redirect("Searched.aspx");
    > }
    > catch (Exception ex)
    > {
    > Debug.WriteLine(
    > "WWWPage.Search_Click(): exception: " +
    > ex.Message);
    > }
    > }
    >
    > Unfortunatelly Redirect does not work. Here what I found in Output
    > window:
    >
    > WWWPage.Search_Click()
    > A first chance exception of type
    > 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
    > WWWPage.Search_Click(): exception: Thread was being aborted.
    > A first chance exception of type
    > 'System.Threading.ThreadAbortException' occurred in
    > App_Web_2xx5zf8y.dll
    > An exception of type 'System.Threading.ThreadAbortException' occurred
    > in App_Web_2xx5zf8y.dll but was not handled in user code
    >
    > Could you explain me please what is going on and how to correct the
    > problem? My .NET Framework setup was successful, I use Framework a few
    > months and there was no such problems.
    > Thank you very much.
    > /RAM/
    Ray Booysen, May 18, 2006
    #2
    1. Advertising

  3. Just for more insight, Response.Redirect throws a ThreadAbordException
    intentionally. Technically, Response.Redirect calls Response.End() which
    throws the exception.

    If you specify true as a 2nd parameter (by default it's false),
    Response.End() isn't called, and the page is fully processed before being
    redirected.

    The real solution to your problem is not to swallow exceptions like you are
    doing. You really shouldn't ever catch Exception.

    Karl

    --
    http://www.openmymind.net/



    "Ray Booysen" <> wrote in message
    news:%23zMGi%...
    > Try:
    >
    > Response.redirect("Searched.aspx", true);
    >
    > and take it out of the try catch.
    >
    > R.A.M. wrote:
    >> Hello,
    >> Could you help me plase?
    >> I have an ASP.NET page with "Search" button; when button is clicked
    >> Search_Click is called; here's the code:
    >>
    >> protected void Search_Click(object sender, EventArgs e)
    >> {
    >> Debug.WriteLine("WWWPage.Search_Click()");
    >> ...
    >> try
    >> {
    >> Response.Redirect("Searched.aspx");
    >> }
    >> catch (Exception ex)
    >> {
    >> Debug.WriteLine(
    >> "WWWPage.Search_Click(): exception: " +
    >> ex.Message);
    >> }
    >> }
    >>
    >> Unfortunatelly Redirect does not work. Here what I found in Output
    >> window:
    >>
    >> WWWPage.Search_Click()
    >> A first chance exception of type
    >> 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
    >> WWWPage.Search_Click(): exception: Thread was being aborted.
    >> A first chance exception of type
    >> 'System.Threading.ThreadAbortException' occurred in
    >> App_Web_2xx5zf8y.dll
    >> An exception of type 'System.Threading.ThreadAbortException' occurred
    >> in App_Web_2xx5zf8y.dll but was not handled in user code
    >>
    >> Could you explain me please what is going on and how to correct the
    >> problem? My .NET Framework setup was successful, I use Framework a few
    >> months and there was no such problems.
    >> Thank you very much.
    >> /RAM/
    Karl Seguin [MVP], May 18, 2006
    #3
  4. You made me think...
    http://codebetter.com/blogs/karlseguin/archive/2006/05/18/144851.aspx

    Karl
    --
    http://www.openmymind.net/



    "Ray Booysen" <> wrote in message
    news:%23zMGi%...
    > Try:
    >
    > Response.redirect("Searched.aspx", true);
    >
    > and take it out of the try catch.
    >
    > R.A.M. wrote:
    >> Hello,
    >> Could you help me plase?
    >> I have an ASP.NET page with "Search" button; when button is clicked
    >> Search_Click is called; here's the code:
    >>
    >> protected void Search_Click(object sender, EventArgs e)
    >> {
    >> Debug.WriteLine("WWWPage.Search_Click()");
    >> ...
    >> try
    >> {
    >> Response.Redirect("Searched.aspx");
    >> }
    >> catch (Exception ex)
    >> {
    >> Debug.WriteLine(
    >> "WWWPage.Search_Click(): exception: " +
    >> ex.Message);
    >> }
    >> }
    >>
    >> Unfortunatelly Redirect does not work. Here what I found in Output
    >> window:
    >>
    >> WWWPage.Search_Click()
    >> A first chance exception of type
    >> 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
    >> WWWPage.Search_Click(): exception: Thread was being aborted.
    >> A first chance exception of type
    >> 'System.Threading.ThreadAbortException' occurred in
    >> App_Web_2xx5zf8y.dll
    >> An exception of type 'System.Threading.ThreadAbortException' occurred
    >> in App_Web_2xx5zf8y.dll but was not handled in user code
    >>
    >> Could you explain me please what is going on and how to correct the
    >> problem? My .NET Framework setup was successful, I use Framework a few
    >> months and there was no such problems.
    >> Thank you very much.
    >> /RAM/
    Karl Seguin [MVP], May 18, 2006
    #4
  5. R.A.M.

    R.A.M. Guest

    On Thu, 18 May 2006 08:49:44 +0100, Ray Booysen
    <> wrote:

    >Try:
    >
    >Response.redirect("Searched.aspx", true);
    >
    >and take it out of the try catch.


    It didn't help. Whatever I write:
    Response.Redirect("Searched.aspx", false);
    Response.Redirect("Searched.aspx", true);
    Response.Redirect("Searched.aspx");
    I have the exception.
    Please help.
    /RAM/
    R.A.M., May 19, 2006
    #5
    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. Stephen Miller
    Replies:
    3
    Views:
    3,967
    Stephen Miller
    Jul 2, 2004
  2. Johanna
    Replies:
    0
    Views:
    604
    Johanna
    Oct 13, 2004
  3. =?Utf-8?B?Sm9oYW5uYQ==?=
    Replies:
    3
    Views:
    1,955
    =?Utf-8?B?Sm9oYW5uYQ==?=
    Oct 15, 2004
  4. Alan Silver
    Replies:
    5
    Views:
    23,066
    Alan Silver
    Dec 6, 2005
  5. Jeff
    Replies:
    3
    Views:
    11,356
    sebichondo
    Feb 3, 2011
Loading...

Share This Page