哪个页面通过 Server.Transfer 进行回发?

发布于 2024-08-20 13:29:08 字数 223 浏览 3 评论 0原文

我有一个简单的表单,可以动态呈现数据输入表单,用户进行回发并将结果保存到数据库中。我创建了一个新版本的表单,并基于数据库上的一些信息,当用户请求旧表单的 URL 时,我想做一个 Server.Transfer 到新的 *.aspx 页面来生成页面并处理回发。由于页面的 URL 不会改变,这是否意味着回发会发送到原始页面?然后我是否需要检查它是否是回发,如果是,则调用 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. 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

勿挽旧人 2024-08-27 13:29:08

这取决于您所说的“获取”回发的含义。当然,第一页将获取发布的表单值,因为它们是从客户端发送的。但是,第一页对回发信息做出反应的程度取决于您在生命周期中何时启动 Server.Transfer。如果它在生命周期中非常晚(例如单击处理程序),那么第一页将几乎完成整个回发过程。

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. 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.

み零 2024-08-27 13:29:08

查看 Server.Transfer 之后页面的 HTML 源代码。如果表单的操作是新的 ASPX 那么就可以了。

使用常规重定向可能会更容易。这样你就不会遇到此类问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文