PostBack

  • Thread starter Thread starter Uriah Piddle
  • Start date Start date
U

Uriah Piddle

Hi Gang,

As far as transferring data goes, is putting a context.response.redirect
statement in an event handler basically the same as setting the PostBackUrl
prop for a control? So far, none of my pages use data from a previous page.
Assuming that these two methods both send their data to the new page, would
it be good practice to use the Server.Transfer method of navigating whenever
no data from the previous page is needed? Thanks.

Steve
 
Response.Redirect differs from PostBackUrl in that Redirect requires
an extra round trip to the server.

With Redirect the normal flow is that a page will post back to itself,
some processing will be done on the server, and then it will send a
http redirect to the client telling the browser to request the new
page. So there is an extra client-side redirect.

PostBackUrl on the other hand tells the client to post to the second
page immediately. The original page does not receive the postback at
all.

Server.Transfer transfers the page on the server without an associated
client redirect. IMO this is very dangerous and can lead to a ton of
hard to debug problems. We have a general rule never to use
Server.Transfer and if you do comments explaining why are required.
Just some of the problems that arise are relative urls (they'll be
relative to the original page, not the transfered page), incorrect
statistics (the client sees it as a single request, so if you look at
client-side stats for a given page, it'll include time for the
transferred page), and difficulty debugging (if you're getting
aquainted with an app and try to follow the code as you browse around,
the browser and code will not be in sync 'cause the browser doesn't
know what page you're really on after a transfer).

HTH,

Sam


------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.


..
 
Back
Top