Differentiate between Server.Transfer() & Response.Redirect()

Both Server.Transfer and Response.Redirect are ASP.NET objects and are used for navigation between web-pages. However, there are noticeable differences between these two techniques:

Response.Redirect()
  • Response.Redirect() redirects the user to another web-page which may or may not be on the same server. It can redirect the user to an external website on a different server.
  • Response.Redirect() updates the address bar and adds the updated URL to the browser history. User can click back on the browser to navigate to the previous page.
  • Response.Redirect() terminates the request with HTTP 302 status and client-side roundtrip. Client then navigates to the new address and the browser address bar and history updates. The client pays the cost of additional round-trips to the server on each request.
  • Form variables are are not transferred upon a call to Response.Redirect().

Server.Transfer()
  • Server.Transfer() quits current execution of the web-page and redirects the user to another web-page on the same server. It cannot send the user to an external website on a different server.
  • Server.Transfer() keeps the URL unchanged in the address bar. It happens entirely on the server side and the client browser’s address bar remains constant. User cannot click on back button on the browser to navigate to the previous page
  • Server.Transfer() reduces the server request and conserves server resources. It simply changes the focus on the Web Server and transfers the request. With Server.Transfer() there are less number of HTTP requests, which eases pressure on the Web Server and makes the application execute faster.
  • Developer can transfer Query Strings and form variables with a little bug-bashing. The Server.Transfer() method has a second parameter – preserveForm. If this is set to True, the existing query string and form variables will be available to the transferred page. Ex – Server.Transfer(“webpage2”, True);

1 comment:

  1. I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading what you all have to say...
    instant storefront

    ReplyDelete