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

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

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.