Hello
I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop)
The problem is that the Server.Transfer always throws the ThreadAbortException. MSDN acknowledges that this is a unque exception that will be automatically rethrown - i.e. it can't be swallowed. Does anyone know if there is extar code I can write (maybe something in the threading namespace) that effectively swallows this so it doesn't rethrow
For example
Tr
Tr
Server.Transfer("ServB.aspx"
Catch ex As System.Threading.ThreadAbortExceptio
'want to kill thread so it doesn't rethrow to "Second Exception handler
Catch ex As Exceptio
Throw e
End Tr
Catch ex As Exceptio
'Second Exception handle
strEx = ex.Messag
End Tr
Thanks
Mark 9 4583
Hi, Mark
did you try to use simple return; ?
Does this prevent further exceptions?
Alex
"Mark" <an*******@discussions.microsoft.com> wrote in message
news:D6**********************************@microsof t.com... Hello, I'm trying to use a Server.Transfer in a try-catch (I cannot put it
outside the Try-Catch as it is nested deep within a component that is called
in a try-catch loop). The problem is that the Server.Transfer always throws the
ThreadAbortException. MSDN acknowledges that this is a unque exception that
will be automatically rethrown - i.e. it can't be swallowed. Does anyone
know if there is extar code I can write (maybe something in the threading
namespace) that effectively swallows this so it doesn't rethrow? For example:
Try Try Server.Transfer("ServB.aspx") Catch ex As System.Threading.ThreadAbortException 'want to kill thread so it doesn't rethrow to "Second
Exception handler" Catch ex As Exception Throw ex End Try Catch ex As Exception 'Second Exception handler strEx = ex.Message End Try
Thanks, Mark
Hey Alex
Nice suggestion, I tried it and it doesn't work - the exception is still thrown
Mar
----- AlexS wrote: ----
Hi, Mar
did you try to use simple return;
Does this prevent further exceptions
Ale
"Mark" <an*******@discussions.microsoft.com> wrote in messag
news:D6**********************************@microsof t.com.. Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put i
outside the Try-Catch as it is nested deep within a component that is calle
in a try-catch loop) The problem is that the Server.Transfer always throws th
ThreadAbortException. MSDN acknowledges that this is a unque exception tha
will be automatically rethrown - i.e. it can't be swallowed. Does anyon
know if there is extar code I can write (maybe something in the threadin
namespace) that effectively swallows this so it doesn't rethrow For example Tr Tr Server.Transfer("ServB.aspx" Catch ex As System.Threading.ThreadAbortExceptio 'want to kill thread so it doesn't rethrow to "Secon
Exception handler Catch ex As Exceptio Throw e End Tr Catch ex As Exceptio 'Second Exception handle strEx = ex.Messag End Tr Thanks Mar
Calling Server.Transfer is like calling Exit from an exe. It means you
are all done, and processing of this request should end. If you still
have more code that you want to execute after calling Server.Transfer,
then you need to reorganize your code so that executes first, by, for
example, returning a status code from "deep within" your component, that
tells the calling code to execute the transfer.
-Jason
Mark wrote: Hey Alex, Nice suggestion, I tried it and it doesn't work - the exception is still thrown.
Mark
----- AlexS wrote: -----
Hi, Mark
did you try to use simple return; ?
Does this prevent further exceptions?
Alex
"Mark" <an*******@discussions.microsoft.com> wrote in message news:D6**********************************@microsof t.com... > Hello, > I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop). >> The problem is that the Server.Transfer always throws the ThreadAbortException. MSDN acknowledges that this is a unque exception that will be automatically rethrown - i.e. it can't be swallowed. Does anyone know if there is extar code I can write (maybe something in the threading namespace) that effectively swallows this so it doesn't rethrow? >> For example: >> Try > Try > Server.Transfer("ServB.aspx") > Catch ex As System.Threading.ThreadAbortException > 'want to kill thread so it doesn't rethrow to "Second
Exception handler" > Catch ex As Exception > Throw ex > End Try > Catch ex As Exception > 'Second Exception handler > strEx = ex.Message > End Try >> Thanks, > Mark
Try Server.Execute. I don't know if it will help in your exact application
but it may be worth a try.
Dale
"Jason DeFontes" <ja***@defontes.com> wrote in message
news:ux**************@tk2msftngp13.phx.gbl... Calling Server.Transfer is like calling Exit from an exe. It means you are all done, and processing of this request should end. If you still have more code that you want to execute after calling Server.Transfer, then you need to reorganize your code so that executes first, by, for example, returning a status code from "deep within" your component, that tells the calling code to execute the transfer.
-Jason
Mark wrote:
Hey Alex, Nice suggestion, I tried it and it doesn't work - the exception is
still thrown. Mark
----- AlexS wrote: -----
Hi, Mark
did you try to use simple return; ?
Does this prevent further exceptions?
Alex
"Mark" <an*******@discussions.microsoft.com> wrote in message news:D6**********************************@microsof t.com... > Hello, > I'm trying to use a Server.Transfer in a try-catch (I cannot
put it outside the Try-Catch as it is nested deep within a component that
is called in a try-catch loop). >> The problem is that the Server.Transfer always throws the ThreadAbortException. MSDN acknowledges that this is a unque
exception that will be automatically rethrown - i.e. it can't be swallowed. Does
anyone know if there is extar code I can write (maybe something in the
threading namespace) that effectively swallows this so it doesn't rethrow? >> For example: >> Try > Try > Server.Transfer("ServB.aspx") > Catch ex As System.Threading.ThreadAbortException > 'want to kill thread so it doesn't rethrow to
"Second Exception handler" > Catch ex As Exception > Throw ex > End Try > Catch ex As Exception > 'Second Exception handler > strEx = ex.Message > End Try >> Thanks, > Mark
Hey Jason
I thought that Server.Transfer was like a goto, you transfer (goto) from Page A to Page B
I'm not trying to run any code after the server.transfer on page A, rather I'm trying to stop running all Page A code (in this case the try-catch block) and transfer to page B. The problem is that it keeps bubbling up the ThreadAbortException
Any ideas
Thanks
Mar
----- Jason DeFontes wrote: ----
Calling Server.Transfer is like calling Exit from an exe. It means you
are all done, and processing of this request should end. If you still
have more code that you want to execute after calling Server.Transfer,
then you need to reorganize your code so that executes first, by, for
example, returning a status code from "deep within" your component, that
tells the calling code to execute the transfer
-Jaso
Mark wrote Hey Alex Nice suggestion, I tried it and it doesn't work - the exception is still thrown Mar ----- AlexS wrote: ---- Hi, Mar did you try to use simple return; Does this prevent further exceptions Ale "Mark" <an*******@discussions.microsoft.com> wrote in messag news:D6**********************************@microsof t.com.. Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put i outside the Try-Catch as it is nested deep within a component that is calle in a try-catch loop) The problem is that the Server.Transfer always throws th ThreadAbortException. MSDN acknowledges that this is a unque exception tha will be automatically rethrown - i.e. it can't be swallowed. Does anyon know if there is extar code I can write (maybe something in the threadin namespace) that effectively swallows this so it doesn't rethrow For example Tr Tr Server.Transfer("ServB.aspx" Catch ex As System.Threading.ThreadAbortExceptio 'want to kill thread so it doesn't rethrow to "Secon
Exception handler Catch ex As Exceptio Throw e End Tr Catch ex As Exceptio 'Second Exception handle strEx = ex.Messag End Tr Thanks Mar
This is why Server.Transfer throws the exception in the first place, to
unwind the stack so nothing else gets executed. Just leave it alone and
let it do it's thing.
-Jason
Mark wrote: Hey Jason, I thought that Server.Transfer was like a goto, you transfer (goto) from Page A to Page B. I'm not trying to run any code after the server.transfer on page A, rather I'm trying to stop running all Page A code (in this case the try-catch block) and transfer to page B. The problem is that it keeps bubbling up the ThreadAbortException.
Any ideas?
Thanks, Mark
----- Jason DeFontes wrote: -----
Calling Server.Transfer is like calling Exit from an exe. It means you are all done, and processing of this request should end. If you still have more code that you want to execute after calling Server.Transfer, then you need to reorganize your code so that executes first, by, for example, returning a status code from "deep within" your component, that tells the calling code to execute the transfer.
-Jason
Mark wrote:
> Hey Alex, > Nice suggestion, I tried it and it doesn't work - the exception is still thrown. >> Mark >> ----- AlexS wrote: ----- >> Hi, Mark >> did you try to use simple return; ? >> Does this prevent further exceptions? >> Alex >> "Mark" <an*******@discussions.microsoft.com> wrote in message > news:D6**********************************@microsof t.com... >> Hello, >> I'm trying to use a Server.Transfer in a try-catch (I cannot put it > outside the Try-Catch as it is nested deep within a component that is called > in a try-catch loop). >>> The problem is that the Server.Transfer always throws the > ThreadAbortException. MSDN acknowledges that this is a unque exception that > will be automatically rethrown - i.e. it can't be swallowed. Does anyone > know if there is extar code I can write (maybe something in the threading > namespace) that effectively swallows this so it doesn't rethrow? >>> For example: >>> Try >> Try >> Server.Transfer("ServB.aspx") >> Catch ex As System.Threading.ThreadAbortException >> 'want to kill thread so it doesn't rethrow to "Second > Exception handler" >> Catch ex As Exception >> Throw ex >> End Try >> Catch ex As Exception >> 'Second Exception handler >> strEx = ex.Message >> End Try >>> Thanks, >> Mark >>>
The problem is if I just "leave it alone", the exception it throws will be published (global error handler to catch all exceptions and publish them). I am stuck with someone else's architecture that requires me to switch pages with a component that uses Server.Transfer, and therefore an exception will be logged at every new page - which is what I want to avoid
That's why I'm trying to find a way to swallow the ThreadAbortException
Thanks
Mar
----- Jason DeFontes wrote: ----
This is why Server.Transfer throws the exception in the first place, to
unwind the stack so nothing else gets executed. Just leave it alone and
let it do it's thing
-Jaso
Mark wrote Hey Jason I thought that Server.Transfer was like a goto, you transfer (goto) from Page A to Page B I'm not trying to run any code after the server.transfer on page A, rather I'm trying to stop running all Page A code (in this case the try-catch block) and transfer to page B. The problem is that it keeps bubbling up the ThreadAbortException Any ideas Thanks Mar ----- Jason DeFontes wrote: ---- Calling Server.Transfer is like calling Exit from an exe. It means you
are all done, and processing of this request should end. If you still have more code that you want to execute after calling Server.Transfer, then you need to reorganize your code so that executes first, by, for example, returning a status code from "deep within" your component, that tells the calling code to execute the transfer -Jaso Mark wrote Hey Alex Nice suggestion, I tried it and it doesn't work - the exception is still thrown Mar ----- AlexS wrote: ---- Hi, Mar did you try to use simple return; Does this prevent further exceptions Ale "Mark" <an*******@discussions.microsoft.com> wrote in messag news:D6**********************************@microsof t.com.. Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put i outside the Try-Catch as it is nested deep within a component that is calle in a try-catch loop) The problem is that the Server.Transfer always throws th ThreadAbortException. MSDN acknowledges that this is a unque exception tha will be automatically rethrown - i.e. it can't be swallowed. Does anyon know if there is extar code I can write (maybe something in the threadin namespace) that effectively swallows this so it doesn't rethrow For example Tr Tr Server.Transfer("ServB.aspx" Catch ex As System.Threading.ThreadAbortExceptio 'want to kill thread so it doesn't rethrow to "Secon Exception handler Catch ex As Exceptio Throw e End Tr Catch ex As Exceptio 'Second Exception handle strEx = ex.Messag End Tr Thanks Mar
I think your only option is to ignore the ThreadAbortException in your
logging. Possibly you can inspect the stack trace of the exception and
only ignore it if Server.Transfer is in the stack.
-Jason
Mark wrote: The problem is if I just "leave it alone", the exception it throws will be published (global error handler to catch all exceptions and publish them). I am stuck with someone else's architecture that requires me to switch pages with a component that uses Server.Transfer, and therefore an exception will be logged at every new page - which is what I want to avoid.
That's why I'm trying to find a way to swallow the ThreadAbortException.
Thanks, Mark
----- Jason DeFontes wrote: -----
This is why Server.Transfer throws the exception in the first place, to unwind the stack so nothing else gets executed. Just leave it alone and let it do it's thing.
-Jason
Mark wrote: > Hey Jason, > I thought that Server.Transfer was like a goto, you transfer (goto) from Page A to Page B. > I'm not trying to run any code after the server.transfer on page A, rather I'm trying to stop running all Page A code (in this case the try-catch block) and transfer to page B. The problem is that it keeps bubbling up the ThreadAbortException. >> Any ideas? >> Thanks, > Mark >>> ----- Jason DeFontes wrote: ----- >> Calling Server.Transfer is like calling Exit from an exe. It means you > are all done, and processing of this request should end. If you still > have more code that you want to execute after calling Server.Transfer, > then you need to reorganize your code so that executes first, by, for > example, returning a status code from "deep within" your component, that > tells the calling code to execute the transfer. >> -Jason >> Mark wrote: >>> Hey Alex, >> Nice suggestion, I tried it and it doesn't work - the exception is still thrown. >>> Mark >>> ----- AlexS wrote: ----- >>> Hi, Mark >>> did you try to use simple return; ? >>> Does this prevent further exceptions? >>> Alex >>> "Mark" <an*******@discussions.microsoft.com> wrote in message >> news:D6**********************************@microsof t.com... >>> Hello, >>> I'm trying to use a Server.Transfer in a try-catch (I cannot put it >> outside the Try-Catch as it is nested deep within a component that is called >> in a try-catch loop). >>>> The problem is that the Server.Transfer always throws the >> ThreadAbortException. MSDN acknowledges that this is a unque exception that >> will be automatically rethrown - i.e. it can't be swallowed. Does anyone >> know if there is extar code I can write (maybe something in the threading >> namespace) that effectively swallows this so it doesn't rethrow? >>>> For example: >>>> Try >>> Try >>> Server.Transfer("ServB.aspx") >>> Catch ex As System.Threading.ThreadAbortException >>> 'want to kill thread so it doesn't rethrow to "Second >> Exception handler" >>> Catch ex As Exception >>> Throw ex >>> End Try >>> Catch ex As Exception >>> 'Second Exception handler >>> strEx = ex.Message >>> End Try >>>> Thanks, >>> Mark >>>>
Server.Execute is like a goto. It runs the code in the new page and returns
to the original page. In fact, you'll even end up with two sets of header
HTML tags in the client source.
Server.Transfer is more like changing processes.
Dale
"Mark" <an*******@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com... Hey Jason, I thought that Server.Transfer was like a goto, you transfer (goto) from
Page A to Page B. I'm not trying to run any code after the server.transfer on page A, rather
I'm trying to stop running all Page A code (in this case the try-catch
block) and transfer to page B. The problem is that it keeps bubbling up the
ThreadAbortException. Any ideas?
Thanks, Mark
----- Jason DeFontes wrote: -----
Calling Server.Transfer is like calling Exit from an exe. It means
you are all done, and processing of this request should end. If you still have more code that you want to execute after calling
Server.Transfer, then you need to reorganize your code so that executes first, by, for example, returning a status code from "deep within" your component,
that tells the calling code to execute the transfer.
-Jason
Mark wrote:
> Hey Alex, > Nice suggestion, I tried it and it doesn't work - the exception
is still thrown. >> Mark >> ----- AlexS wrote: ----- >> Hi, Mark >> did you try to use simple return; ? >> Does this prevent further exceptions? >> Alex >> "Mark" <an*******@discussions.microsoft.com> wrote in message > news:D6**********************************@microsof t.com... >> Hello, >> I'm trying to use a Server.Transfer in a try-catch (I cannot put
it > outside the Try-Catch as it is nested deep within a component
that is called > in a try-catch loop). >>> The problem is that the Server.Transfer always throws the > ThreadAbortException. MSDN acknowledges that this is a unque
exception that > will be automatically rethrown - i.e. it can't be swallowed.
Does anyone > know if there is extar code I can write (maybe something in
the threading > namespace) that effectively swallows this so it doesn't
rethrow? >>> For example: >>> Try >> Try >> Server.Transfer("ServB.aspx") >> Catch ex As System.Threading.ThreadAbortException >> 'want to kill thread so it doesn't rethrow to
"Second > Exception handler" >> Catch ex As Exception >> Throw ex >> End Try >> Catch ex As Exception >> 'Second Exception handler >> strEx = ex.Message >> End Try >>> Thanks, >> Mark >>> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: StephenMcC |
last post by:
Hi All,
Got a quick query in relation to the Server.Transfer method available in IIS
5+/ASP. I've got an issue where I want to take a portion of an online app and
extract this out into a web...
|
by: Manuel Lopez |
last post by:
Hello,
We have two applications that will reside on the same webserver.
We want to be able to post from pages in App1 to to pages in App2.
We need to pass sensible data, so we cannot use...
|
by: Julien C. |
last post by:
Hi all,
I have an "EditeItem.aspx" page which lets me edit properties of an "Item".
In the OnClick() event of my Save button, I do save Item changes to the
database and then I redirect the user...
|
by: Nedu N |
last post by:
Hi All,
I am facing a typical problem in my .NET application with the pop-up script
messages. The thing is that its working fine when i run on my development
machine but not running in expected...
|
by: Alexander Bosch |
last post by:
Hi,
I'm having a problem similar to the one that's stated in this KB
http://support.microsoft.com/default.aspx?scid=kb;en-us;839521
When I'm posting a page to itself with the bool value as true it...
|
by: UJ |
last post by:
Folks,
We provide custom content for our customers. Currently we put the files on
our server and people have a program we provide that will download the
files. These files are usually SWF, HTML or...
|
by: bryan |
last post by:
I've got a custom HttpHandler to process all requests for a given
extension. It gets invoked OK, but if I try to do a Server.Transfer I
get an HttpException. A Response.Redirect works, but I really...
|
by: Henry |
last post by:
Hello
I'm using server.transfer() to navigate between pages, and I don't
understand why the URL changes while navigating.
My start page is default.aspx and from a button I want to navigate to...
|
by: n# |
last post by:
A Basic Question in ASP.NEt 1.1
In Page_Load Event I am doing a Server.Transfer.
But it throws an error on the browser windows showing "Server
Application Not Found"
Pls help me
|
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= |
last post by:
Hi,
I'm using Threads, and when I try to do Server.Transfer, I recieved an
error. (child object does not exist...)
My Code:
Dim t As New Thread(AddressOf Hilo)
Private Sub Hilo()...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
| |