I just implemented a page that performs a Response.Redirect(url, true). As
such, I wrapped it in a try catch, and explicitly caught a
ThreadAbortException. However, the thread abort exception was still thrown
at every catch block above the try/catches level, as well as at the *same*
level as the try/catch. This does not seem like proper behavior at all. Once
I've caught the exception, why is it still propagating up the stack? I could
maybe understand it going up the stack, but how it it getting into catch
blocks at the same level? Below is some code that illustrates what happened.
function void doStuff(string url) {
try {
try {
Response.Redirect(url, true);
} catch (ThreadAbortException) {
//This is hit
Logger.Log("Aborted");
}
try {
} catch (Exception e) {
//This is hit.
Logger.Log(e, "Aborted same level");
}
} catch (Exception e) {
//This is hit.
Logger.Log(e, "Aborted level above");
}
}
All of those Log statements are hit unless for each one I put a "catch
(ThreadAbortException)" in there. What is going on here, and why?
Thanks,
Steve 3 1885
I dont know why it is behaving like this in your case. But you can avoid the
threadabortexception by passing "false" as second parameter to
response.redirect.
--
Saravana
Microsoft MVP - ASP.NET www.extremeexperts.com
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl... I just implemented a page that performs a Response.Redirect(url, true). As such, I wrapped it in a try catch, and explicitly caught a ThreadAbortException. However, the thread abort exception was still thrown at every catch block above the try/catches level, as well as at the *same* level as the try/catch. This does not seem like proper behavior at all.
Once I've caught the exception, why is it still propagating up the stack? I
could maybe understand it going up the stack, but how it it getting into catch blocks at the same level? Below is some code that illustrates what
happened. function void doStuff(string url) { try { try { Response.Redirect(url, true); } catch (ThreadAbortException) { //This is hit Logger.Log("Aborted"); }
try {
} catch (Exception e) { //This is hit. Logger.Log(e, "Aborted same level"); } } catch (Exception e) { //This is hit. Logger.Log(e, "Aborted level above"); } }
All of those Log statements are hit unless for each one I put a "catch (ThreadAbortException)" in there. What is going on here, and why?
Thanks, Steve
But then it will continue to process any code left on the page, won't it? So
I would have to implement a class level variable indicating that no further
processing should occur. Correct?
Steve
"Saravana [MVP]" <sa******@sct.co.in.nospam> wrote in message
news:ul*************@TK2MSFTNGP11.phx.gbl... I dont know why it is behaving like this in your case. But you can avoid
the threadabortexception by passing "false" as second parameter to response.redirect.
-- Saravana Microsoft MVP - ASP.NET www.extremeexperts.com
You are correct, it will process the code after response.redirect. If you
dont want it to happen, then you shouldnt pass "false" as the parameter
value for EndResponse parameter.
--
Saravana
Microsoft MVP - ASP.NET www.extremeexperts.com
"Steve - DND" <steve!@!digitalnothing.com> wrote in message
news:eh*************@TK2MSFTNGP10.phx.gbl... But then it will continue to process any code left on the page, won't it?
So I would have to implement a class level variable indicating that no
further processing should occur. Correct?
Steve
"Saravana [MVP]" <sa******@sct.co.in.nospam> wrote in message news:ul*************@TK2MSFTNGP11.phx.gbl... I dont know why it is behaving like this in your case. But you can avoid the threadabortexception by passing "false" as second parameter to response.redirect.
-- Saravana Microsoft MVP - ASP.NET www.extremeexperts.com
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: amit kumar |
last post by:
I am calling a function which returns pointer to a map.
The declaration of the map is map<int,vectxyz*>. vectxyz is a vector
containing pointer to a class xyz.
For map<int,vectxyz*>* p1
In the...
|
by: Stephan Steiner |
last post by:
Hi
I'm having some weird threading issues.. almost at random, if I dare change
a line of my code, the shutdown sequence gets messed up.
I'm using a thread to receive data from the network, that...
|
by: Mark Phillips |
last post by:
Hello,
I am having a problem in which a file can get stuck open when a thread
that is attempting to write to it gets aborted (ThreadAbortedException
occurs). The log file gets stuck open until...
|
by: Vivek |
last post by:
Hi,
I have a question regarding ThreadAbortException. Why is the thread abort
exception rethrown at the end of a catch clause?
Why is ThreadAbortException's behavior designed to be this way?
...
|
by: David Waz... |
last post by:
Moved an app from W/2000 Asp V1.0 to
W/2003, VS/2003, ASPV 1.1
Page runs a long job, uploading 2 large fixed length files
(300,000 rows) into SQL database. A process is run
against the data,...
|
by: splap20 |
last post by:
Every day a large chunk of XML is posted up to my app via http. The app
interprets this XML and writes results to a SQLServer. Occasionally a
ThreadAbortException is thrown during this process....
|
by: foolmelon |
last post by:
If a childThread is in the middle of a catch block and handling an
exception caught, the main thread calls childThread.Abort(). At that
time a ThreadAbortException is thrown in the childThread. ...
|
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= |
last post by:
Hi,
I am running a web service which sometimes throws exceptions. I have a
lot of error trapping within the web service, but I have missed the current
problem. I am working on the current issue,...
|
by: Zeba |
last post by:
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |