简体   繁体   English

哪个页面通过Server.Transfer获得回发?

[英]Which page gets the postback with Server.Transfer?

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. 我创建了新版本的表单,并根据数据库上的一些信息,当用户请求旧表单的URL时,我想执行Server.Transfer到新的* .aspx页面以生成页面,并处理回发。 Since the URL of the page will not change, does that mean the postback gets sent to the original page? 由于页面的URL不会更改,这是否意味着回发已发送到原始页面? 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? 然后,我需要检查它是否为回发,如果是,则调用Server.Transfer并允许将表单数据传输到新页面?

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. 但是,首页对回发信息的反应程度取决于在生命周期中何时启动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. 用于在Server.Transfer中保留表单值可选参数指示第二页是否也对请求做出响应,就像它是回发一样。

Take a look at the HTML source of the page after the Server.Transfer. 在Server.Transfer之后,查看页面的HTML源代码。 If the form's action is the new ASPX then you are okay. 如果表单的操作是新的ASPX,那么您可以。

It would probably be easier to use a regular redirect. 使用常规重定向可能会更容易。 That way you don't have these kinds of issues. 这样,您就不会遇到这类问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM