467,920 Members | 1,108 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,920 developers. It's quick & easy.

What's the difference between Response.Redirect and Server.Transfer?

Hello,

Sorry if this is a stupid question, but I can't really see much
difference between these tow methods according to the scant info in the
SDK.

Could anyone enlighten me? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
  • viewed: 5163
Share:
3 Replies
Alan Silver <al*********@nospam.thanx> wrote in
news:5K**************@nospamthankyou.spam:
Sorry if this is a stupid question, but I can't really see much
difference between these tow methods according to the scant info in
the SDK.


Server.Transfer does a server side transfer.

Response.Redirect does a client side redirect - the server informs the
browser to redirect.

So here's the flow:

Server Transfer

1. Client Request Page HelloWorld.ASPX
2. Server.Transfer -> Server send a different page to the client
3. Client Receives Page still thinking it's HelloWorld.ASPX.
4. Client's URL (Address bar) remains HelloWorld.ASPX since the page was
sent on the server side and the client doesn't know a different page was
sent.

Response.Redirect

1. Client Requests Page HelloWorld.ASPX
2. Response.Redirect -> Server sends a HTTP header informing that the
user should redirect. 3. Client sees the redirect notice and requests
AnotherPage.ASPX 4. Server sends AnotherPage.ASPX
5. Client's URL (address bar) shows AnotherPage.ASPX

Technically speaking, Server.Trasfer is faster since there 1 less
roundtrip, but you lose the URL of the page. Server.Transfer also allows
for more flexibilty since you can use HTTPContext.Items to pass
variables beteen pages.

However, I only use Server.Transfer when i need to pass context items.
Otherwise I use Response.Redirect so the user will always see the
correct URL in the address bar.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
Also, after a server.transfer, Context.Handler will refer to the initial
page, with no way of getting the new page (as far as i know)...certainly a
pita when you run into it and didn't know :)

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
Alan Silver <al*********@nospam.thanx> wrote in
news:5K**************@nospamthankyou.spam:
Sorry if this is a stupid question, but I can't really see much
difference between these tow methods according to the scant info in
the SDK.


Server.Transfer does a server side transfer.

Response.Redirect does a client side redirect - the server informs the
browser to redirect.

So here's the flow:

Server Transfer

1. Client Request Page HelloWorld.ASPX
2. Server.Transfer -> Server send a different page to the client
3. Client Receives Page still thinking it's HelloWorld.ASPX.
4. Client's URL (Address bar) remains HelloWorld.ASPX since the page was
sent on the server side and the client doesn't know a different page was
sent.

Response.Redirect

1. Client Requests Page HelloWorld.ASPX
2. Response.Redirect -> Server sends a HTTP header informing that the
user should redirect. 3. Client sees the redirect notice and requests
AnotherPage.ASPX 4. Server sends AnotherPage.ASPX
5. Client's URL (address bar) shows AnotherPage.ASPX

Technically speaking, Server.Trasfer is faster since there 1 less
roundtrip, but you lose the URL of the page. Server.Transfer also allows
for more flexibilty since you can use HTTPContext.Items to pass
variables beteen pages.

However, I only use Server.Transfer when i need to pass context items.
Otherwise I use Response.Redirect so the user will always see the
correct URL in the address bar.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 19 '05 #3
Thanks, that was a very clear answer.
Sorry if this is a stupid question, but I can't really see much
difference between these tow methods according to the scant info in
the SDK.


Server.Transfer does a server side transfer.

Response.Redirect does a client side redirect - the server informs the
browser to redirect.

So here's the flow:

Server Transfer

1. Client Request Page HelloWorld.ASPX
2. Server.Transfer -> Server send a different page to the client
3. Client Receives Page still thinking it's HelloWorld.ASPX.
4. Client's URL (Address bar) remains HelloWorld.ASPX since the page was
sent on the server side and the client doesn't know a different page was
sent.

Response.Redirect

1. Client Requests Page HelloWorld.ASPX
2. Response.Redirect -> Server sends a HTTP header informing that the
user should redirect. 3. Client sees the redirect notice and requests
AnotherPage.ASPX 4. Server sends AnotherPage.ASPX
5. Client's URL (address bar) shows AnotherPage.ASPX

Technically speaking, Server.Trasfer is faster since there 1 less
roundtrip, but you lose the URL of the page. Server.Transfer also allows
for more flexibilty since you can use HTTPContext.Items to pass
variables beteen pages.

However, I only use Server.Transfer when i need to pass context items.
Otherwise I use Response.Redirect so the user will always see the
correct URL in the address bar.


--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Harsh Thakur | last post: by
9 posts views Thread by odwrotnie | last post: by
20 posts views Thread by Simon Says | last post: by
3 posts views Thread by jasonheath.net | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.