Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Server.Transfer VS. Response.Redirect

Server.Transfer VS. Response.Redirect

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netvisual-studiosysadminquestion
7 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    frank21
    wrote on last edited by
    #1

    Hello All, I have an ASP.NET app with about 5 or 6 aspx pages. I have a starting page and allow the user to select items from a list box and I carry these items from page to page using Session["whatever"] = "blah". I am trying to make my application run as fast as possible and was wondering which method of page changing is faster? Server.Transfer or Response.Redirect. Any advice you could give would be much appreciated. Thanks for helping out a newbie! Frank

    K H P 3 Replies Last reply
    0
    • F frank21

      Hello All, I have an ASP.NET app with about 5 or 6 aspx pages. I have a starting page and allow the user to select items from a list box and I carry these items from page to page using Session["whatever"] = "blah". I am trying to make my application run as fast as possible and was wondering which method of page changing is faster? Server.Transfer or Response.Redirect. Any advice you could give would be much appreciated. Thanks for helping out a newbie! Frank

      K Offline
      K Offline
      krisman
      wrote on last edited by
      #2

      Hi. From one newbie to another, I have found that Server.Transfer is the faster of the two, at least over at my development site. Krisman

      1 Reply Last reply
      0
      • F frank21

        Hello All, I have an ASP.NET app with about 5 or 6 aspx pages. I have a starting page and allow the user to select items from a list box and I carry these items from page to page using Session["whatever"] = "blah". I am trying to make my application run as fast as possible and was wondering which method of page changing is faster? Server.Transfer or Response.Redirect. Any advice you could give would be much appreciated. Thanks for helping out a newbie! Frank

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Technically, Server.Transfer is not a page redirect. Response.Redirect sends the HTTP Location: header to redirect the browser to a different page. Conversely, Server.Transfer executes the page code from a different page that is output to the client as though it was the page they request. The browser is not redirected at all. So, the question of which one is faster isn't really relevent. It's all based on your implementation of whether or not you want the client browser to be redirected to another page or - in some sense - have the server do it.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        G 1 Reply Last reply
        0
        • F frank21

          Hello All, I have an ASP.NET app with about 5 or 6 aspx pages. I have a starting page and allow the user to select items from a list box and I carry these items from page to page using Session["whatever"] = "blah". I am trying to make my application run as fast as possible and was wondering which method of page changing is faster? Server.Transfer or Response.Redirect. Any advice you could give would be much appreciated. Thanks for helping out a newbie! Frank

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Heath is right, they serve different purposes. Also note you cannot have querystring data in a Server.Transfer. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

          N 1 Reply Last reply
          0
          • P Paul Watson

            Heath is right, they serve different purposes. Also note you cannot have querystring data in a Server.Transfer. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            If you specify, the query string and any form data can be passed along during the transfer. Provided it has any relevance to the new page of course. Server.Transfer("newpage.aspx", true);

            P 1 Reply Last reply
            0
            • N Not Active

              If you specify, the query string and any form data can be passed along during the transfer. Provided it has any relevance to the new page of course. Server.Transfer("newpage.aspx", true);

              P Offline
              P Offline
              Paul Watson
              wrote on last edited by
              #6

              What I meant was you can't go Server.Transfer("newpage.aspx_?var1=val1&var2=val2_", true); like you can with Response.Redirect. But thanks for the info, I knew it transferred form collection data but not existing querystring data. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

              1 Reply Last reply
              0
              • H Heath Stewart

                Technically, Server.Transfer is not a page redirect. Response.Redirect sends the HTTP Location: header to redirect the browser to a different page. Conversely, Server.Transfer executes the page code from a different page that is output to the client as though it was the page they request. The browser is not redirected at all. So, the question of which one is faster isn't really relevent. It's all based on your implementation of whether or not you want the client browser to be redirected to another page or - in some sense - have the server do it.

                -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                G Offline
                G Offline
                Geoff Kushnir
                wrote on last edited by
                #7

                To add to Heath's reply, the evidence of this is in the address bar. If you use a Server.Transfer you will see the address of the page has not changed, due to the fact that processing has stopped on the original page and transferred to the new page. Conversely, if you use Response.Redirect you will see the address of the new page in the address bar. Not sure if this matters but it may be relevant. Just because I don't care, doesn't mean I don't understand. - Homer J. Simpson

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups