When using Server.Transfer, the entire Asp.Net life cycle is executed?

I understand that Server.Transfer does not return back to the requesting client.

What I was not able to find out is simply to transfer control directly to the new request handler that you pass in, or if the entire request life cycle is executed again.

I assume that the entire life cycle is executed again using the transfer URL, but he wanted to make sure that it is.

+4
source share
2 answers

Here is what I found during the experiments.

When using Server.Transfer entire request life cycle does not start again.

If you are writing your own module, connect it to the request life cycle and call Server.Transfer from this module, the rest of the request life cycle will be skipped and the page life cycle will begin immediately.

Upon completion of the life cycle of the transfer page, the life cycle of the request selects backups with its tearing events. Please note that the HtppContext for tear events will be the original that you switched from. That is, the URL and QueryString values ​​will be the same as the original query, and not the URL and QueryString values ​​for the page that you clicked on.

Server.Transfer modifies the HttpContext.Request object to contain the new URL and QueryString information during the life cycle of the page for the page you are redirected to.

If you go to a resource that is not a page but a text one (for example, something.xml), the contents of this page will be returned in the same way as with its encoding set to text / html.

If you go to a resource that is not a page and is not based on text (for example, something.pdf), then an HttpException will be thrown. This happens even if you define a custom handler for this resource.

+3
source

He just went along with his condition. The request life cycle does not start again, although the page life cycle will be executed for the page you are going to.

http://msdn.microsoft.com/en-us/library/ms525800(v=vs.90).aspx

Server.Transfer acts as an effective replacement for the Response.Redirect method. Response.Redirect tells the browser to request another page. Since the redirect forces a new page request, the browser makes two requests to the web server, so the web server processes an additional request. IIS 5.0 introduces a new Server.Transfer function that transfers execution to another ASP page on the server. This avoids the additional request, which leads to an increase in the overall system performance, as well as to a better user experience.

This link is also useful -
http://www.developer.com/net/asp/article.php/3299641/ServerTransfer-Vs-ResponseRedirect.htm

+1
source

All Articles