Tuesday, September 9, 2008

The difference between Server.Transfer and Response.Redirect in ASP .NET

Server.Transfer processes the page from one page directly to the next page without making a round-trip back to the client's browser. This way is faster, with a little less overhead on the server.
However, it does not update the clients url history list or current url.

Response.Redirect, as expected, is used to redirect the user's browser to another page or site. It does perform a trip back to the client where the client's browser is actually redirected to the new page.
The browser history list is updated to reflect the new address.

Source: https://www.nilebits.com/blog/2008/05/difference-between-server-transfer-response-redirect-asp-dot-net/

4 comments:

  1. thank u for useful info.....but if server.transfer is a better is that means we dont have to use response.redirect any more?

    ReplyDelete
  2. Well, it depends on your case.
    Because you can’t use query string in Server.Transfer, so this is not the perfect solution after all.

    ReplyDelete
  3. hi,
    you can use query string with server.transfere if you set the preserveForm param to true.
    and i consider 2 functionality is diff. it's not the same sport :))

    if you are trying to pass an object to the another page. using the httpcontext. you cant use redirect thing.

    also server.transfer can't send the user to external site.

    simply redirect tells the browser to visit another page.

    ReplyDelete
  4. Do you have a spam problem on this website; I also am a blogger, and
    I was curious avout your situation; many of us have developped some nice practices and we are looking
    to trade strategies with others, please shoot me an e-mail if
    interested.

    ReplyDelete