Thread was being aborted

jenwardwell

Newcomer
Joined
Aug 11, 2003
Messages
2
Location
Virginia Beach, Virginia
I also get this same error message. Here are some more details on it:

Error Number: 5
Error Description: Thread was being aborted.
Exception Message: Thread was being aborted.
Exception Type: System.Threading.ThreadAbortException
Base Exception: Thread was being aborted.
Base Exception Type: System.SystemException
 
I'm having this problem too.

What does this mean exactly? I thought that server.transfer stopped execution of the current code and transfered to the new page... Should I add an exit sub or something???

Or maybe I should throw an error and let a main error handler deal with the error??

I can't seem to find any decent examples of how to handle error handling in ASP.NET, and my books from Amazon won't arrive for another couple of days...
 
It seems to everyone get the same error, when I use Response.Redirect or Server.Transfer, then this error will occurs.

I found this problem since the first day I use ASP.NET (more than 1 year)... but still not idea about it...
 
The problem is, I can't put the response.redirect outside the try... catch block...

But I just curious is it bugs or what?
 
It is normal for a Server.Transfer to have a ThreadAbortException, so if you need a try/catch in that routine simply ignore the abort exception and catch everything else.
 
The problem is when I use Try/Catch and encounter "Server.Transfer", then it will not execute code below. I can ignore the exception only after it was 'catch' right?
 
Thread is being aborted

you can still use the
Try block but this is the way you need to do it.

Try

Catch e as exception

Finally

Response.Redirect("") 'this will work here

End Try
 
Hello,

I have found a work arround for this problem below is the way i have implemented

Try
<Your Code>

TransferPage()
Catch ex as Exception
If ex.GetType.ToString.ToLower = "system.threading.threadabortexception" Then
TransferPage()
Else
DisplayError(ex)
End If

Finaly

End try

Protected Sub TransferPage()
Response.Redirect("<your required location>")
End Sub


Hope this will help...
 
(or preferably)

Catch ex as System.Threading.Threadabortexception
... do nothing

as Robby says, this always happens, and I've seen it in every ASP.NET app I've worked on, so deal with it
 
I would imagine this problem occurs because the try catch block is the unfinished thread another way round it to be sure the thread has completed would be.

c#

// Used as workaround because
// Response.Redirect Creates error inside try catch block

bool responseRedirect = false;

try {

// Do STUFF here

responseRedirect = true;

}
catch {

// Do error Stuff

}

// Will only occur if responseRedirect = true
if (responseRedirect) {

Response.Redirect("CandidateList.aspx");

}
 
Info from MS

from the Microsoft site:

ThreadAbortException is a special exception that can be caught by application code, but is re-thrown at the end of the catch block unless ResetAbort is called. ResetAbort cancels the request to abort, and prevents the ThreadAbortException from terminating the thread. Unexecuted finally blocks are executed before the thread is aborted.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadclassaborttopic2.asp
 
details about redirect:

[C#]
public void Redirect(
string url,
bool endResponse
);

URL
The target location.
endResponse
Indicates whether execution of the current page should terminate.


so, i.e. set endResponse to false and execution of the following code in your method will be executed.

example Response.Redirect("bla.aspx", false);
 
Hi Guys!

Please use -> Response.Redirect("yourpage", false)
instead of -> Response.Redirect("yourpage")

This is is the only bull happening here

bye and regards.

SHIMAIL AHMED GILLANI
KARACHI, PAKISTAN
 
shimail said:
Hi Guys!

Please use -> Response.Redirect("yourpage", false)
instead of -> Response.Redirect("yourpage")

This is is the only bull happening here

bye and regards.

SHIMAIL AHMED GILLANI
KARACHI, PAKISTAN

Have followed the example, no exception being thrown, but I am getting the following error: "A page can have only one server-side Form tag."

Where to now?

Mike55.
 
Back
Top