Usama Mosaad
What is the difference between Server.Transfer method and Response.Redirect method?
By Usama Mosaad in ASP.NET on Feb 25 2009
  • Purushottam Rathore
    Feb, 2009 26

    Response.Redirect simply sends a message to the browser, telling it to move to another page.

    For Example:

    1. Response.Redirect("default.aspx");
    2. Response.Redirect("http://www.c-sharpcorner.com/")

    Server.Transfer is similar in that it sends the user to another page:

    For Example:

    Server.Transfer("default.aspx").

    Difference between Server.Transfer method and Response.Redirect method.

    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 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 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.

    • 0
  • Shashi Ray
    Feb, 2009 26

    The Transfer method allows you to transfer from inside one ASP page to another ASP page. All of the state information that has been created for the first (calling) ASP page will be transferred to the second (called) ASP page. This transferred information includes all objects and variables that have been given a value in an Application or Session scope, and all items in the Request collections. For example, the second ASP page will have the same SessionID as the first ASP page.

    When the second (called) ASP page completes its tasks, you do not return to the first (calling) ASP page. All these happen on the server side browser is not aware of this.
    The redirect message issue HTTP 304 to the browser and causes browser to got the specified page. Hence there is round trip between client and server. Unlike transfer, redirect doesn’t pass context information to the called page.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS