Search code examples
asp.netresponse.redirectserver.transfer

if child of server.execute calls Server.Transfer or handler.ProcessRequest or Response.Redirect, what happens?


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?


Solution

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