TransferRequest vs Transfer in ASP.Net

Sujit picture Sujit · Feb 21, 2013 · Viewed 13k times · Source

I have gone through the links mentioned below,

iis forum and HttpModules & Server.Transfer / Server.TransferRequest / RewritePath problems. but unable to catch the concept behind these transfer methods.

How are they works? And which one is preferred in different situation?

Can someone explain me TransferRequest vs Transfer methods for server side transfer in asp.net and its roles?

Thanks in advance

Answer

Sujit picture Sujit · May 16, 2013

HttpServerUtility.Transfer Terminates execution of the current page and starts execution of provided URL. This basically maps and executes a new ASP.NET Page (or serves a static file) corresponding to the url provided. It does this in-place in the current request pipeline, without applying new configuration to the new url, or re-running IIS modules for the new url. Because of this, its very fast, but it also prevents a lot of scenarios that are possible with TRQ.

HttpServerUtility.TransferRequest Performs an asynchronous execution of the provided URL. This is a full IIS child request under the covers, which allows it to re-run the entire request pipeline for the new request as if it was a separate request, getting the correct configuration for it, and running all of the normal IIS modules including authentication, authorization, etc. For example, IIS will apply the authorization rules for the new url, as opposed to the previous url.