473,382 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How Dangerous Is Server.Transfer?

I've been reading up on Server.Transfer as well as doing some testing, and
it appears to always raise the ThreadAbortException error. On one hand I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortException - but the MSDN
documentation says Server.Transfer will always cause that exception - by
design - and that the work-around is to not use Server.Transfer (and to use
Server.Execute instead). Surprising indeed. "Here's a great new tool - now
don't use it" is what I'm hearing from Microsoft about Server.Transfer. This
is confusing to me. Am I just missing something? Is ThreadAbortException
really not all that bad? I've read elsewhere that it really is bad and to
avoid it at all costs.

I'd appreciate it if anyone could clarify whether Server.Transfer is okay to
use even though it always causes a ThreadAbortException.

Thanks!
Nov 18 '05 #1
5 2544
hi,

When you call Server.Transfer it terminates the currently executing thread
and goes ahead and redirects to the new page.
Since the thread is terminated a ThreadAbortException is thrown by the
runtime.

Having said that, Its perfectly fine to use Server.Transfer even if it
throws a ThreadAbortException. Just make sure you have no Try-Catch blocks
wrapping the Server.Transfer statement else the exception will keep getting
caught.
Nov 18 '05 #2
You may find relevent information here.
http://support.microsoft.com/default...b;EN-US;312629
http://blogs.msdn.com/bleroy/archive...03/207486.aspx

"Guadala Harry" <GM**@NoSpam.com> ¦b¶l¥ó
news:en**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and
it appears to always raise the ThreadAbortException error. On one hand I've read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortException - but the MSDN documentation says Server.Transfer will always cause that exception - by
design - and that the work-around is to not use Server.Transfer (and to use Server.Execute instead). Surprising indeed. "Here's a great new tool - now
don't use it" is what I'm hearing from Microsoft about Server.Transfer. This is confusing to me. Am I just missing something? Is ThreadAbortException
really not all that bad? I've read elsewhere that it really is bad and to
avoid it at all costs.

I'd appreciate it if anyone could clarify whether Server.Transfer is okay to use even though it always causes a ThreadAbortException.

Thanks!

Nov 18 '05 #3
The articles you provided are exactly the ones that inspired my post! The
first one is the one that explicitly states that one should NOT use
Server.Transfer and instead use Server.Execute as a workaround for "this
problem" which is also "by design".... Thus my initial confusion. We have a
situation that is created by design: I clearly understand *why*
ThreadAbortException is raised. I clearly understand that I have alternative
ways to transfer users around my application. What I'm still not sure of is
the extent to which Server.Transfer is dangerous (or not). In the second
link you provided (thank you - I should have provided those in my OP), the
author states about ending a response, "This is a very violent thing to do."
Very violent? I'll buy it - this guy seems to know his stuff and is
apparently a credible source. So, I'm wondering, if it is in fact, "very
violent," then should I ever knowingly let it happen in my application? I
think the obvious ansers is "of course you should never knowingly let a very
violent thing happen" in your application. The implication is that one
should, then, *never* user Server.Transfer because it *always* results in
the original response being terminated (which is a "very violent" thing).

Perhaps I'm just being overly cautious here (okay, paranoid). I'd really
like to know because I really like the idea of being able to use
Server.Transfer. I'm just rather uncomfortable ThreadAbortException
knowingly occuring. Is ThreadAbortException really not hurting anything; and
I would be perfectly responsible to let it happen as a matter of routine in
a busy application? I'd really like to know as Server.Transfer is otherwise
a godsend in certain situations. Thanks!

The fact that you're paranoid doesn't mean you're not being followed!

GH


"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
You may find relevent information here.
http://support.microsoft.com/default...b;EN-US;312629
http://blogs.msdn.com/bleroy/archive...03/207486.aspx

"Guadala Harry" <GM**@NoSpam.com> ¦b¶l¥ó
news:en**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortException - but the

MSDN
documentation says Server.Transfer will always cause that exception - by
design - and that the work-around is to not use Server.Transfer (and to

use
Server.Execute instead). Surprising indeed. "Here's a great new tool - now don't use it" is what I'm hearing from Microsoft about Server.Transfer.

This
is confusing to me. Am I just missing something? Is ThreadAbortException
really not all that bad? I've read elsewhere that it really is bad and to avoid it at all costs.

I'd appreciate it if anyone could clarify whether Server.Transfer is

okay to
use even though it always causes a ThreadAbortException.

Thanks!


Nov 18 '05 #4
Hi Guadala,

I know we talked about this on another thread, and this is another one
of the reasons I still like URL rewriting as a first choice to solve
these types of problems.

However, given the chice between letting a response continue (which
could be exepensive) and aborting the response with an exception, I
imagine the team thought it might use fewer resources to throw an
exception. Obviosuly, this isn't the case in a page designed to only
do transfers or redirects.

Server.Transfer is "clean looking" from a coding point of view, but
all these approaches have some drawbacks.

--
Scott
http://www.OdeToCode.com/

On Fri, 8 Oct 2004 05:33:33 -0700, "Guadala Harry" <GM**@NoSpam.com>
wrote:
The articles you provided are exactly the ones that inspired my post! The
first one is the one that explicitly states that one should NOT use
Server.Transfer and instead use Server.Execute as a workaround for "this
problem" which is also "by design".... Thus my initial confusion. We have a
situation that is created by design: I clearly understand *why*
ThreadAbortException is raised. I clearly understand that I have alternative
ways to transfer users around my application. What I'm still not sure of is
the extent to which Server.Transfer is dangerous (or not). In the second
link you provided (thank you - I should have provided those in my OP), the
author states about ending a response, "This is a very violent thing to do."
Very violent? I'll buy it - this guy seems to know his stuff and is
apparently a credible source. So, I'm wondering, if it is in fact, "very
violent," then should I ever knowingly let it happen in my application? I
think the obvious ansers is "of course you should never knowingly let a very
violent thing happen" in your application. The implication is that one
should, then, *never* user Server.Transfer because it *always* results in
the original response being terminated (which is a "very violent" thing).

Perhaps I'm just being overly cautious here (okay, paranoid). I'd really
like to know because I really like the idea of being able to use
Server.Transfer. I'm just rather uncomfortable ThreadAbortException
knowingly occuring. Is ThreadAbortException really not hurting anything; and
I would be perfectly responsible to let it happen as a matter of routine in
a busy application? I'd really like to know as Server.Transfer is otherwise
a godsend in certain situations. Thanks!

The fact that you're paranoid doesn't mean you're not being followed!

GH


"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
You may find relevent information here.
http://support.microsoft.com/default...b;EN-US;312629
http://blogs.msdn.com/bleroy/archive...03/207486.aspx

"Guadala Harry" <GM**@NoSpam.com> ¦b¶l¥ó
news:en**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
> I've been reading up on Server.Transfer as well as doing some testing,and > it appears to always raise the ThreadAbortException error. On one hand

I've
> read a bunch of promotional-type material touting the benefits of
> Server.Transfer and none of them mention ThreadAbortException - but the

MSDN
> documentation says Server.Transfer will always cause that exception - by
> design - and that the work-around is to not use Server.Transfer (and to

use
> Server.Execute instead). Surprising indeed. "Here's a great new tool -now > don't use it" is what I'm hearing from Microsoft about Server.Transfer.

This
> is confusing to me. Am I just missing something? Is ThreadAbortException
> really not all that bad? I've read elsewhere that it really is bad andto > avoid it at all costs.
>
> I'd appreciate it if anyone could clarify whether Server.Transfer is

okay
to
> use even though it always causes a ThreadAbortException.
>
> Thanks!
>
>



Nov 18 '05 #5
I think the most "dangerous" behaviour in this matter is that you may
prematurely end a cleanup algorithum in the middle. This is especially
important if you're using unsafe components that should explicitly call
cleanup yourself.

Actually, I always use Response.Redirect() so this is not a problem with me.
(The overhead to initiate another request is not considered a big problem
here.)

"Guadala Harry" <GM**@NoSpam.com> ¦b¶l¥ó
news:uE*************@TK2MSFTNGP11.phx.gbl ¤¤¼¶¼g...
The articles you provided are exactly the ones that inspired my post! The
first one is the one that explicitly states that one should NOT use
Server.Transfer and instead use Server.Execute as a workaround for "this
problem" which is also "by design".... Thus my initial confusion. We have a situation that is created by design: I clearly understand *why*
ThreadAbortException is raised. I clearly understand that I have alternative ways to transfer users around my application. What I'm still not sure of is the extent to which Server.Transfer is dangerous (or not). In the second
link you provided (thank you - I should have provided those in my OP), the
author states about ending a response, "This is a very violent thing to do." Very violent? I'll buy it - this guy seems to know his stuff and is
apparently a credible source. So, I'm wondering, if it is in fact, "very
violent," then should I ever knowingly let it happen in my application? I
think the obvious ansers is "of course you should never knowingly let a very violent thing happen" in your application. The implication is that one
should, then, *never* user Server.Transfer because it *always* results in
the original response being terminated (which is a "very violent" thing).

Perhaps I'm just being overly cautious here (okay, paranoid). I'd really
like to know because I really like the idea of being able to use
Server.Transfer. I'm just rather uncomfortable ThreadAbortException
knowingly occuring. Is ThreadAbortException really not hurting anything; and I would be perfectly responsible to let it happen as a matter of routine in a busy application? I'd really like to know as Server.Transfer is otherwise a godsend in certain situations. Thanks!

The fact that you're paranoid doesn't mean you're not being followed!

GH


"Lau Lei Cheong" <le****@yehoo.com.hk> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
You may find relevent information here.
http://support.microsoft.com/default...b;EN-US;312629
http://blogs.msdn.com/bleroy/archive...03/207486.aspx

"Guadala Harry" <GM**@NoSpam.com> ¦b¶l¥ó
news:en**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand

I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortException - but the
MSDN
documentation says Server.Transfer will always cause that exception -
by design - and that the work-around is to not use Server.Transfer (and to
use
Server.Execute instead). Surprising indeed. "Here's a great new tool - now don't use it" is what I'm hearing from Microsoft about
Server.Transfer. This
is confusing to me. Am I just missing something? Is

ThreadAbortException really not all that bad? I've read elsewhere that it really is bad and

to avoid it at all costs.

I'd appreciate it if anyone could clarify whether Server.Transfer is

okay
to
use even though it always causes a ThreadAbortException.

Thanks!



Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Harsh Thakur | last post by:
Hi, I'd like to know the performance related differences between Response.Redirect and Server.Transfer. I'd like to redirect the user to a different page. I can either do a...
5
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...
9
by: Mark | last post by:
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...
11
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...
1
by: veenakj | last post by:
Hi Code snippet -------------- strErrMsg = "Could not find a part of the path \"C:\\Temp\\data\\Test.xml\"." } Server.Transfer("Message.aspx?errormsg=" + Server.UrlEncode(lsErrMsg));...
8
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...
6
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
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
2
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()...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
0
BarryA
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...
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.