469,913 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

2.0: unexpected exception "Thread was being aborted"

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/
May 18 '06 #1
4 2664
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/

May 18 '06 #2
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" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
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/

May 18 '06 #3
You made me think...
http://codebetter.com/blogs/karlsegu...18/144851.aspx

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

"Ray Booysen" <rj***********@rjb.za.net> wrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
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/

May 18 '06 #4
On Thu, 18 May 2006 08:49:44 +0100, Ray Booysen
<rj***********@rjb.za.net> 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/
May 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Elliot M. Rodriguez | last post: by
4 posts views Thread by hitendra15 | last post: by
1 post views Thread by R.A.M. | last post: by
2 posts views Thread by =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.