What is the difference between Server.Transfer and Response.Redirect?
What is the difference between Server.Transfer and Response.Redirect?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Mar 17, 2011, 12:09 AM
The Server.Transfer method is not supported by ajax controls.
Initial days during Ajax CTK released this bug came up, but dont know still there is a fix for it.
Every one recommends to use Response.Redirect only for Ajax Controls.
Andrew FensterPosted Mar 16, 2011, 9:30 PM
I would just add that Server.Transfer is more efficient (as Vijay says), but sometimes you need to do a Response.Redirect anyhow. Maybe you want a Javascript method to fire once before redirecting.
Some of the Ajax Control Toolkit controls (all written in Javascript) won't work quite right unless you do a Response.Redirect.
Vijay YadavPosted Mar 16, 2011, 5:51 AM
Hi,
Both "Server" and "Response" are objects of ASP.NET. Server.Transfer and Response.Redirect both are used to transfer a user from one page to another. But there is an underlying difference.
//Usage of Server.Transfer & Response.Redirect
Server.Transfer("Page2.aspx");
Response.Redirect("Page2.aspx");
The Response.Redirect statement sends a command back to the browser to request the next page from the server. This extra round-trip is often inefficient and unnecessary, but this established standard works very well. By the time Page2 is requested, Page1 has been flushed from the server's memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc.
The more efficient Server.Transfer method simply renders the next page to the browser without an extra round trip. Variables can stay in scope and Page2 can read properties directly from Page1 because it's still in memory. This technique would be ideal if it wasn't for the fact that the browser is never notified that the page has changed. Therefore, the address bar in the browser will still show "Page1.aspx" even though the Server.Transfer statement actually caused Page2.aspx to be rendered instead. This may occasionally be a good thing from a security perspective, it often causes problems related to the browser being out of touch with the server. Say, the user reloads the page, the browser will request Page1.aspx instead of the true page (Page2.aspx) that they were viewing. In most cases, Response.Redirect and Server.Transfer can be used interchangeably. But in some cases, efficiency or usability may be the deciding factor in choosing.
Krishna GaradPosted Mar 16, 2011, 5:44 AM
Response.redirect will only get method to post variables form one page to another means we need to give in query string if we want to pass some variables to next page.
But in server.transfer if we selected the second attribute to TRUE then it will post all the variable using the post method.