3

Or vice versa.

Update:
Hmm, let's assume I have a shopping cart app, the user clicks on the Checkout button. The next thing I want to do is send the user to a Invoice.aspx page (or similar). When the user hits checkout, I could Button.PostBackURL = "Invoice.aspx"

or I could do

Server.Transfer("Invoice.aspx")

(I also changed the title since the method is called Transfer and not TransferURL)

ColdFire
  • 6,764
  • 6
  • 35
  • 51
Matt R
  • 2,577
  • 5
  • 30
  • 46

3 Answers3

6
  • Server.TransferURL will not result in a roundtrip of HTTP request/response. The address bar will not update, as far as the browser knows it has received only one document. Server.Transfer also retains execution context, so the script "keeps going" as opposed to "starts anew".
  • PostbackURL ensures an HTTP request, resulting in a possibly different URL and of course incurring network latency costs.

Usually when you are attempting to "decide between the two" it means you are better off using PostbackURL.

Feel free to expand your question with specifics and we can look at your precise needs.

  • Matt R: I just saw your update. you should definitely use PostBackURL in this scenario unless you are ready to do extensive testing and research with Server.Transfer – Dave Carroll Oct 07 '08 at 16:30
3

Here is a good breakdown between the two:

Server.Transfer vs Response.Redirect

Thunder3
  • 1,120
  • 1
  • 7
  • 10
1

Server.Transfer is done entirely from the server. Postback is initiated from the client for posting form contents and postback url identifies the page to post to.

Maybe you meant to compare with Response.Redirect, which forces the client to submit a new request for a new url.

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170