English 中文(简体)
哪一页会接收到具有 Server.Transfer 的 postback?
原标题:Which page gets the postback with Server.Transfer?

我有一个简单的表单,可以动态呈现数据输入表单,用户进行回传,结果保存到数据库。我创建了一个新版本的表单,并基于数据库上的一些信息,当用户请求旧表单的URL时,我希望对新的*.aspx页面进行服务器传送来生成页面并处理回传。由于页面的URL不会改变,这是否意味着回传被发送到原始页面?那么我是否需要检查它是否是回传,如果是那么调用服务器传送,并允许表单数据被传送到新页面?

最佳回答

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

在Server.Transfer中,用于保留表单值的可选参数决定第二个页面是否也会像它是一个postback请求一样对请求做出反应。

问题回答

在 Server.Transfer 之后查看页面的 HTML 源代码。如果表单的 action 是新的 ASPX,则说明一切正常。

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





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签