Monday, May 31, 2010

What is the difference between Server.Transfer and Response.Redirect?

Server.Transfer(): Using this statement it not only redirects to the next page but also all the content of the page is transferred to next page. Data is persisted to next pages using Context.ItemCollection which keeps the page state alive.

Response.Redirect(): Using this statement the Context.Items loses the persistence to transfer the content to next page. Hence every page is treated as a seperate page.

1 comments:

Madhulika said...

Just to add up a little more points

Server.Transfer
We can transfer only to pages within our web application. We cannot transfer to yahoo.com

It does not update the browser url.
It may be a problem when users want to bookmark the page.

It processes from one page to the next without making a roundtrip back to the client browser (so url is not updated).
So it is faster


Response.Redirect
We can transfer to page within our application and also other pages.

It updates the browser url.

This performs a roundtrip back to the client browser (url is updated).
So it is slower.

Post a Comment