Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between response.redirect and server.transfer [duplicate]

Tags:

c#

asp.net

Possible Duplicates:
Response.Redirect vs. Server.Transfer
Server.Transfer Vs. Response.Redirect

What is the difference between response.redirect and server.transfer? Only one difference i know is: In response.redirect the browser url changes to targeted page as well as in server.transfer the url remains same! any other difference?

like image 804
SMK Avatar asked Jul 21 '11 15:07

SMK


People also ask

What is the difference between response redirect () and server transfer ()?

Response. Redirect simply sends a message (HTTP 302) down to the browser. Server. Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

Which one is better response redirect VS server transfer?

Redirect from one application to another application, it will be redirected. It means that we cannot be redirected out of the server application using server. Transfer that is only used for navigating within the same application.

What can I use instead of a response redirect?

For instance, instead of a "form" button that causes a postback and redirect, you could use a LinkButton that will behave like a hyperlink, allowing the browser to request the new page directly.

What is the difference between server transfer and server execute?

Transfer ends the current web form and begin executing a new web form. Server. Execute begins executing a new web form while still displaying the current web form. The contents of both forms are combined.


1 Answers

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

like image 186
Pit Digger Avatar answered Oct 01 '22 23:10

Pit Digger