如果 server.execute 的子级调用 Server.Transfer 或 handler.ProcessRequest 或 Response.Redirect,会发生什么?

发布于 2024-10-03 01:42:47 字数 602 浏览 0 评论 0原文

我正在尝试运行(在 try 块中,没有 catch,但有一个 finally)

HttpContext.Current.Server.Execute(child1, tw, true);

,其中子页面尝试运行以下操作之一:

context.Response.Redirect(child2.uri.ToString());
handler.ProcessRequest(context); //context has had items added to update querystring
context.Server.Transfer(child2.uri.ToString());

我可以期望控制权返回到我的原始页面吗?我想我可能 - 一旦代码到达(例如)Server.Transfer,我发现自己回到了我的finally块中的原始父页面(但我的Server.Execute之后的任何代码都被跳过)。

请注意,如果我只是重定向到第一个子页面,它就可以正常工作,但随后我必须传递 cookie 来跨越登录障碍(我试图使用 Server.Execute 来绕过该障碍)。

这些嵌套执行、传输和重定向的预期行为是什么?

I'm trying to run (in a try block, with no catch but a finally)

HttpContext.Current.Server.Execute(child1, tw, true);

where the child page tries to run one of the following:

context.Response.Redirect(child2.uri.ToString());
handler.ProcessRequest(context); //context has had items added to update querystring
context.Server.Transfer(child2.uri.ToString());

Can I expect control to ever return to my original page? I suppose I might - Once the code reaches (for example) Server.Transfer, I find myself back on my original parent page in my finally block (but any code after my Server.Execute has been skipped).

As a note, the first child page works fine if I simply redirect to it, but then I have to pass cookies to cross a login barrier (that I'm trying to circumvent with Server.Execute).

What is the expected behavior of these nested executes and transfers and redirects?

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

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

发布评论

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

评论(1

左岸枫 2024-10-10 01:42:47

回答我自己的问题:

是的。一旦子请求完成处理,Execute 最终将收回控制权 - Server.Transfer 的情况将传输子请求,但不会传输父请求。

Answering my own question:

Yes. Execute will eventually take control back once the child requests finish processing - the case of the Server.Transfer will transfer the child request but not the parent.

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