By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Server.Transfer vs. Response.Redirect

P: n/a
Since both methods seem to produce the same results, in which cases
would you prefer one over the other? The only thing I would think is
using Server.Transfer because of some browsers blocking redirects.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Server.Transfer saves you one round trip to the client. As a result, client
is unaware of the transfer and keeps showing original url in its url field
which is misleading. Just one of the considerations.

Eliyahu

"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Since both methods seem to produce the same results, in which cases
would you prefer one over the other? The only thing I would think is
using Server.Transfer because of some browsers blocking redirects.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #2

P: n/a
Response.Redirect tells the client the new URL that should be hit.

Server.Transfer is server side and the client doesn't know the new location
which could be a problem.

Still I've got mayself a hard time to find out a legitimate use for
Server.Transfer / Server.Execute. I always thought it's here mainly for
legacy as it always looks like to me the reason is that you embedded some
processing in a particular ASPX page which is not especially desirable ?

Hopefully someone will pop up with a legitimate use I didn't thought
about...

Patrice

--

"Terry Olsen" <to******@hotmail.com> a crit dans le message de
news:%2****************@TK2MSFTNGP14.phx.gbl...
Since both methods seem to produce the same results, in which cases
would you prefer one over the other? The only thing I would think is
using Server.Transfer because of some browsers blocking redirects.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #3

P: n/a
Response.Redirect requires an extra round trip between the browser and the
server, therefore it is less efficient. However, at least this keeps the
browser informed of what's going on so it can display the correct URL in the
address bar.
Server.Transfer is more efficient, and it masks the true URL of the page
from the browser, which can be a good thing sometimes but is more often a
hassle (such as when the user reloads the browser page and the browser then
requests the wrong page.)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Terry Olsen" <to******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Since both methods seem to produce the same results, in which cases
would you prefer one over the other? The only thing I would think is
using Server.Transfer because of some browsers blocking redirects.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #4

P: n/a
Using the Transfer method is very similar to executing a hyperlink or using
the Redirect method, with one difference: Transfer can retain some
information from the source page across requests. Setting the Transfer
method' s preserveForm argument to True makes the form' s QueryString,
ViewState, and event procedure information available in the destination form.

To use the Transfer method with preserveForm set to True, you must first set
the EnableViewStateMac attribute in the Web form' s Page directive to False.
By default, ASP.NET hashes ViewState information, and setting this attribute
to False disables that hashing so the information can be read on the
subsequent Web form.

And You can't use the Transfer method with HTML pages. It works only with
..aspx pages. For example, Request.Redirect(“my_html.htm”) is right but
Server.Transfer(“my_html.htm”) is wrong.

HTH

Elton Wang
el********@hotmail.com

"Terry Olsen" wrote:
Since both methods seem to produce the same results, in which cases
would you prefer one over the other? The only thing I would think is
using Server.Transfer because of some browsers blocking redirects.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.