Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Difference between Response.Redirect and Server.Transfer.Where we have to use these two with example.
Posted
Comments
[no name] 12-Jul-12 14:32pm    
Pasting your text into google produces over 80000 results. Do you have a specific question?
Gaurav Aroraa 30-Oct-14 17:14pm    
There are lot of articles and blog posts in CodeProject, you can refer to those

Response.Redirect involves an extra round-trip to the server whereas Server.Transfer conserves server resources by avoiding that extra round-trip. Server.Transfer just changes the focus of the page by directly communicating with server.

Here, read:
Response.Redirect[^]
Vs
Server.Transfer[^]

Response.Redirect
sends HTTP code 302 down to the users browser along with the new URL location of the wanted page. HTTP Code 302 actually means ' The requested resource resides temporarily under a different URI'.
BUT
Server.Transfer do not initiates another request to the server, but the original request is simply rewritten and transfered to some other page on the same server.

Then these:
What is the difference between Server.Transfer and Response.Redirect methods? [^]
Difference between Server.Transfer() and Response.Redirect()[^]


Summary:

    Response.Redirect should be used when:

  • we want to redirect the request to some plain HTML pages on our server or to some other web server
  • we don't care about causing additional roundtrips to the server on each request
  • we do not need to preserve Query String and Form Variables from the original request
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)
  • Server.Transfer should be used when:

  • we want to transfer current page request to another .aspx page on the same server
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server
  • we want to preserve Query String and Form Variables (optionally)
  • we don't need to show the real URL where we redirected the request in the users Web Browser
 
Share this answer
 
Response.Redirect should be used when:

we want to redirect the request to some plain HTML pages on our server or to some other web server

we don't care about causing additional roundtrips to the server on each request

we do not need to preserve Query String and Form Variables from the original request

we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)

Server.Transfer should be used when:

we want to transfer current page request to another .aspx page on the same server

we want to preserve server resources and avoid the unnecessary roundtrips to the server

we want to preserve Query String and Form Variables (optionally)

we don't need to show the real URL where we redirected the request in the users Web Browser
 
Share this answer
 
Following are the major differences between them:-
√ Response.Redirect sends message to the browser saying it to move to some
different page, while server.transfer does not send any message to the browser
but rather redirects the user directly from the server itself. So in server.transfer
there is no round trip while response.redirect has a round trip and hence puts
a load on server.
√ Using Server.Transfer you can not redirect to a different from the server itself.
Example if your server is www.yahoo.com you can use server.transfer to move
to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e.
within websites. This cross server redirect is possible only using
Response.redirect.
√ With server.transfer you can preserve your information. It has a parameter
called as “preserveForm”. So the existing query string etc. will be able in the
calling page. In response.redirect you can maintain the state, but has
lot of drawbacks.
 
Share this answer
 
The main difference between them is who does the transfer. In "response.redirect" the transfer is done by the browser while in "server.transfer" it’s done by the server.

Below is a great video which explains the same in more detail.

https://www.facebook.com/photo.php?v=762186150488997[^]
 
Share this answer
 
v2
Comments
Shivprasad koirala 20-May-14 7:12am    
Not sure this question was updated or looked new so answered it.
 
Share this answer
 
Comments
CHill60 20-May-14 6:50am    
Homework question was posted 2 years ago
King Fisher 20-May-14 7:10am    
i saw this Question at Top of the Quick Answers List.so i thought new Question ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900