views:

155

answers:

2

I have a simple form that dynamically presents a data entry form, and the user does a postback and the results are saved to a database. I have created a new version of the form, and based on some information on a database, when the user requests the URL of the old form, I wanted to do a Server.Transfer to the new *.aspx page to generate the page and handle the postback. Since the URL of the page will not change, does that mean the postback gets sent to the original page? Would I then need to check if it's a postback, and if so then call Server.Transfer and allow the form data to be transfered to the new page?

+2  A: 

It depends on what you mean by "gets" the postback. The first page will get the form values posted of course, since they are sent from the client. However, how far the first page gets through reacting to the postback information depends on when in the lifecycle you initiate the Server.Transfer. If it is extremely late in the lifecycle (like a click handler), then the first page will have pretty much gone through the entire postback process.

The optional parameter to preserve form values in Server.Transfer dictates whether the second page also reacts to the request as if it is a postback.

Rex M
I am doing the Server.Transfer on the Get request in Page.Load. So the Transfer has been done once for the get request, which is the point of confusion for me. After the client receives the response(generated by the Server.Transfer), and then performs a Postback, do I need logic in the original page to essentially redo the Server.Transfer.
AaronLS
When I say gets the postback, I mean when a postback occurs, which page receives the request: the one in the URL, or the one that was transfered to via Server.Transfer during the original get request.
AaronLS
@aaronls From the perspective of the client, only the first page receives the request. From the perspective of the individual pages, they both receive a request which happens to be the same one.
Rex M
+1  A: 

Take a look at the HTML source of the page after the Server.Transfer. If the form's action is the new ASPX then you are okay.

It would probably be easier to use a regular redirect. That way you don't have these kinds of issues.

David
A redirect will not re-post.
Rex M