Server.Transfer vs. Response.Redirect

Discussion in 'ASP .Net' started by Terry Olsen, Jun 15, 2005.

  1. Terry Olsen

    Terry Olsen Guest

    Since both methods seem to produce the same results, in which cases
    would you prefer one over the other? The only thing I would think is
    using Server.Transfer because of some browsers blocking redirects.

    *** Sent via Developersdex http://www.developersdex.com ***
    Terry Olsen, Jun 15, 2005
    #1
    1. Advertising

  2. Terry Olsen

    Patrice Guest

    Response.Redirect tells the client the new URL that should be hit.

    Server.Transfer is server side and the client doesn't know the new location
    which could be a problem.

    Still I've got mayself a hard time to find out a legitimate use for
    Server.Transfer / Server.Execute. I always thought it's here mainly for
    legacy as it always looks like to me the reason is that you embedded some
    processing in a particular ASPX page which is not especially desirable ?

    Hopefully someone will pop up with a legitimate use I didn't thought
    about...

    Patrice

    --

    "Terry Olsen" <> a écrit dans le message de
    news:%...
    > Since both methods seem to produce the same results, in which cases
    > would you prefer one over the other? The only thing I would think is
    > using Server.Transfer because of some browsers blocking redirects.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Patrice, Jun 15, 2005
    #2
    1. Advertising

  3. Server.Transfer saves you one round trip to the client. As a result, client
    is unaware of the transfer and keeps showing original url in its url field
    which is misleading. Just one of the considerations.

    Eliyahu

    "Terry Olsen" <> wrote in message
    news:%...
    > Since both methods seem to produce the same results, in which cases
    > would you prefer one over the other? The only thing I would think is
    > using Server.Transfer because of some browsers blocking redirects.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Eliyahu Goldin, Jun 15, 2005
    #3
  4. Response.Redirect requires an extra round trip between the browser and the
    server, therefore it is less efficient. However, at least this keeps the
    browser informed of what's going on so it can display the correct URL in the
    address bar.
    Server.Transfer is more efficient, and it masks the true URL of the page
    from the browser, which can be a good thing sometimes but is more often a
    hassle (such as when the user reloads the browser page and the browser then
    requests the wrong page.)

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Terry Olsen" <> wrote in message
    news:%...
    > Since both methods seem to produce the same results, in which cases
    > would you prefer one over the other? The only thing I would think is
    > using Server.Transfer because of some browsers blocking redirects.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    Steve C. Orr [MVP, MCSD], Jun 15, 2005
    #4
  5. Using the Transfer method is very similar to executing a hyperlink or using
    the Redirect method, with one difference: Transfer can retain some
    information from the source page across requests. Setting the Transfer
    method' s preserveForm argument to True makes the form' s QueryString,
    ViewState, and event procedure information available in the destination form.

    To use the Transfer method with preserveForm set to True, you must first set
    the EnableViewStateMac attribute in the Web form' s Page directive to False.
    By default, ASP.NET hashes ViewState information, and setting this attribute
    to False disables that hashing so the information can be read on the
    subsequent Web form.

    And You can't use the Transfer method with HTML pages. It works only with
    ..aspx pages. For example, Request.Redirect(“my_html.htmâ€) is right but
    Server.Transfer(“my_html.htmâ€) is wrong.

    HTH

    Elton Wang




    "Terry Olsen" wrote:

    > Since both methods seem to produce the same results, in which cases
    > would you prefer one over the other? The only thing I would think is
    > using Server.Transfer because of some browsers blocking redirects.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
    =?Utf-8?B?RWx0b24gVw==?=, Jun 15, 2005
    #5
  6. Terry Olsen

    niranjan44

    Joined:
    Jun 2, 2011
    Messages:
    4
    niranjan44, Jun 3, 2011
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin
    Replies:
    3
    Views:
    537
    Cowboy \(Gregory A. Beamer\)
    Jul 31, 2003
  2. Harsh Thakur

    Response.Redirect vs Server.Transfer

    Harsh Thakur, Aug 18, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    774
    Harsh Thakur
    Aug 18, 2003
  3. yma
    Replies:
    2
    Views:
    423
    Kevin Spencer
    Dec 4, 2003
  4. Sal
    Replies:
    1
    Views:
    399
  5. David C. Holley

    server.execute/response.redirect/server.transfer

    David C. Holley, Jan 17, 2004, in forum: ASP General
    Replies:
    6
    Views:
    432
    David Holley
    Jan 18, 2004
Loading...

Share This Page