473,545 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ThreadAbortExce ption error. On one hand I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortExce ption - 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 ThreadAbortExce ption
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 ThreadAbortExce ption.

Thanks!
Nov 18 '05 #1
5 2561
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 ThreadAbortExce ption is thrown by the
runtime.

Having said that, Its perfectly fine to use Server.Transfer even if it
throws a ThreadAbortExce ption. 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.co m> ¦b¶l¥ó
news:en******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and
it appears to always raise the ThreadAbortExce ption error. On one hand I've read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortExce ption - 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 ThreadAbortExce ption
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 ThreadAbortExce ption.

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*
ThreadAbortExce ption 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 ThreadAbortExce ption
knowingly occuring. Is ThreadAbortExce ption 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.c om.hk> wrote in message
news:ON******** ******@TK2MSFTN GP10.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.co m> ¦b¶l¥ó
news:en******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortExce ption error. On one hand I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortExce ption - 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 ThreadAbortExce ption
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 ThreadAbortExce ption.

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.co m>
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.Transfe r 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*
ThreadAbortExc eption 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.Transfe r. I'm just rather uncomfortable ThreadAbortExce ption
knowingly occuring. Is ThreadAbortExce ption 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.c om.hk> wrote in message
news:ON******* *******@TK2MSFT NGP10.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.co m> ¦b¶l¥ó
news:en******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
> I've been reading up on Server.Transfer as well as doing some testing,and > it appears to always raise the ThreadAbortExce ption error. On one hand

I've
> read a bunch of promotional-type material touting the benefits of
> Server.Transfer and none of them mention ThreadAbortExce ption - 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 ThreadAbortExce ption
> 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 ThreadAbortExce ption.
>
> 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.Redire ct() 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.co m> ¦b¶l¥ó
news:uE******** *****@TK2MSFTNG P11.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*
ThreadAbortExce ption 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 ThreadAbortExce ption
knowingly occuring. Is ThreadAbortExce ption 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.c om.hk> wrote in message
news:ON******** ******@TK2MSFTN GP10.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.co m> ¦b¶l¥ó
news:en******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g...
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortExce ption error. On one hand

I've
read a bunch of promotional-type material touting the benefits of
Server.Transfer and none of them mention ThreadAbortExce ption - 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

ThreadAbortExce ption 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 ThreadAbortExce ption.

Thanks!



Nov 18 '05 #6

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

Similar topics

4
2092
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 Response.Redirect("URL") or a Server.Transfer("URL"). So I'd like to find out which is more efficient/better. Can anyone please tell me or give any pointers to links on...
5
7810
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 to the Item page "ViewItem.aspx" with a simple : Server.Transfer("ViewItem.aspx"); I'd like to pass another HTTP parameter so that in the...
9
4594
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 Server.Transfer always throws the ThreadAbortException. MSDN acknowledges that this is a unque exception that will be automatically rethrown - i.e....
11
6004
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 falls into an infinite loop and later a StackOverflow Exception. I need to do this and not a Response.Redirect or a transfer with the bool in...
1
2592
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
3878
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 need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the...
6
2175
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
3991
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. In my masterpage I have this: private bool m_AlreadyTested; public bool AlreadyTested { get { return m_AlreadyTested; }
2
3091
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() Thread.Sleep(1000)
0
7465
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7752
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5969
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.