You must Sign In to post a response.
  • Category: .NET

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

    The forum thread has not been reviewed by Editors yet. Readers are advised to use their best judgement before accessing this thread.
    This thread will be reviewed shortly.
    If you think this thread contain inappropriate content, please report to webmaster.
    I want to know that what is the difference between Server.Transfer and Response.Redirect ??? Pls. it's very urgent....
  • #30247
    Hope this will make it more clear to you to achive for the answer you are looking for.

    Response.Redirect simply sends a message down to the browser, telling it to move to another page. So, you may run code like:

    Response.Redirect("WebForm2.aspx")
    or

    Response.Redirect("http://www.karlmoore.com/")
    to send the user to another page.

    Server.Transfer is similar in that it sends the user to another page with a statement such as Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and disadvantages.

    Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

    But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.

    Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

    That's not all: The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

    For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").

    This technique is great for wizard-style input forms split over multiple pages. But there's another thing you'll want to watch out for when using the preserveForm parameter. ASP.NET has a bug whereby, in certain situations, an error will occur when attempting to transfer the form and query string values. You'll find this documented at http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920.

    The unofficial solution is to set the enableViewStateMac property to True on the page you'll be transferring to, then set it back to False. This records that you want a definitive False value for this property and resolves the bug.

    So, in brief: Response.Redirect simply tells the browser to visit another page. Server.Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables.

    Top Tip: Don't confuse Server.Transfer with Server.Execute, which executes the page and returns the results. It was useful in the past, but, with ASP.NET, it's been replaced with fresher methods of development. Ignore it.

  • #30248
    Well, Response.Redirect simply sends a message down to the browser, telling it to move to another page. So, you may run code like:

    Response.Redirect("WebForm2.aspx")

    Server.Transfer is similar in that it sends the user to another page with a statement such as Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and disadvantages.

    Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

    But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.
    Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

    That's not all: The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

    For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").
    Response.Redirect simply tells the browser to visit another page. Server.Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables.

  • #280183
    Response.Redirect..
    If the requested page is in new location, this informs the browser.Then the browser initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.

    Server.Transfer..
    The execution is transfered from one page to another page on the server.The browser client is made one request and the initial page is the one responding with content.Also, any posted form variables and query string parameters are available to the second page as well.

    For more ideas, Verify these links..
    http://www.geekinterview.com/question_details/15806
    http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=15
    http://www.dotnetuncle.com/Difference/82_servertransfer_responseredirect.aspx

    Regards
    Sridhar R
    Nothing is illegal, Until You Get Caught

  • #280739
    The "Server.Transfer" Transfers page processing From one Page(site) to the next page(site) without making a round trip Back to the client is browser.
    This provides a faster response with a little less overhead on the server. Server.Transfer dont update the clients url history list or current url.(uniform resorece located) Response.Redirect is used to Redirect the user's browser to Another page or site. This performas a trip Back to the client where the client's browser is redirected to the new page. The user is browser history list is updated to reflect the new address.



    Thanks & Regards
    G.Renganathan
    Nothing is mine ,Everything is yours!!!

  • #281175
    Server.Transfer don't have round trip back to client browser. So client url's still remines the existing the url.
    Response.Redirect have round trip. So client Url(uniform resource locator) will be change.

  • #295032
    Hi,

    The difference between Server.Transfer and Response.Redirect are as follow

    1>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 uyser directly from the server itself.So in Server.transfer their is no round trip while Response.redirect has a round trip hence puts a load on the server.

    2>Using Sever.transfer you cannot redirect to a different server itself while using Response.redirect you can redirect to a different server also.

    3>With Server.transfer you can preserve your information.It has a parameter called as "preserve form",so the existing query string etc will be avilable in the calling page.This is not possible in Response.redirect.

    Regards
    S.S.Bajoria


    Thanks & Regards


    Bunty


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.