Difference between Server.Transfer and Response.Redirect in ASP.NET

What is the difference between Server.Transfer and Response.Redirect? Why you choose one over the other in ASP.NET web application?

Marthe Luis
Views: 7840 | Community Opinion: 12

Tags..  Asp.Net  ASP.Net Interview  ASP.NET web application

Bookmark this page..



Ask a New Question Go to Home

Community Opinion/Answers
 
Raman K Said..

Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url.

Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.




Sandeep Pawar Said..

In Addition to the above using server.Transfer required a virtual Path that means you can transfer the server control to the page within the application and not outside application/site.

e.g

try out
Response.Redirect(''http://www.google.com");
// this will work since it is new request to the browser

Server.Transfer(''http://www.google.com");
// this wont work "A virtual path is expected." error displayed




Md. Shohel Rana Said..

I understand nothing.




Rajesh Said..

we can say that in Server.Transfer("URL") we can pass only that path name which is exist in the current website.where as Response.Redirect("URL") take any url address they may be in current website on not .




Rajeev Mishra Said..

it's Good




vivek k Said..

In simple words
Server.Transfer: It moves from one page to another page without making a round trip
While
Response.Redirect:It move from one page to another page with making a round trip to the browser




sasasdadsad Said..

dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad




dsdasd Said..

sasasdadsad Said..
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
<script>
$("body").css({"display":"none"})
</script>

<style>
body:
{"display":"none"}
</style>




dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsads




sdasdas Said..

dsdasd Said..
sasasdadsad Said..
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad







dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsadsad
dsadsadsadasdsadsadsadsadsads




cprogrammings.com Said..

nice answer...this question ask in interview many times and everyone find this answer on net ...i was searching this question long time..get it but for get more from http://www.cprogrammings.com/result/Different-Between-Response.redirect-and-Server.transfer/44.html




asp madhav Said..

Response.redirect:
Redirects the user to new page which is present in the current webapp or any webapp

Server.Transfer :
Redirects the user to new page which should be present in the current webapp


AS said by sandeep
Response.Redirect(''http://www.google.com");
// this will work since it is new request to the browser
(no path is required as you are redirected to new address)
Server.Transfer(''http://www.google.com");
// this wont work "A virtual path is expected." error displayed
(path is required i.e we need to specify the location exactly as it is not in its web app directory)






What do you think? Add your opinion/answer
*Name
*your opinion/answer: