Response.Redirect vs. Server.Transfer vs. Server.Execute

My quick recap!

Response.Redirect(string url)

  1. Sends a HTTP 302 to the client browser
  2. Client browser does a HTTP-GET of that new page
    That's it.

Note to Redirect Method
Take a look at System.Web.HttpResponse.Redirect in Reflector and see how MS creates a hardcoded html, head, body construct... :-)


Before we meet Server.Transfer meet:
Server.Execute(string page)

  1. Executes the other page
  2. Control-flow jumps to new page and
  3. Returns back if finished...




Server.Transfer(string path)

  1. Sends all of the information that has been assembled for processing by one .aspx file to a the parameter path (.aspx page).


Insight to Server.Transfer
Server.Transfer does a Server.Execute(path, null, true);
but with a Response.End after return from Execute
last param = preserveForm





Advantages of Response.Redirect
Good Can redirect to external urls (even .html or classic asp-pages)
Good Url of new page is in browser adress bar
is this an advantage? :-)

Advantages of Server.Transfer
Good Server.Transfer can pass variables with HTTPContext.Items
Good PreviousPage property access is possible
Good Better performance cause no Client activity is involved
Bad Server.Transfer bypasses the authorization for the page you redirect

References
http://www.dotnetframework.de/dotnet/aspnet2/RedirectVersusTransfer.aspx

http://codebetter.com/blogs/darrell.norton/archive/2003/08/26/1270.aspx

http://weblogs.asp.net/jgalloway/archive/2004/07/21/189547.aspx

http://techahead.wordpress.com/2007/10/14/aspnet-servertransfer-vs-responseredirect/

1 comment:

asd said...

edwewerwerwe

Post a Comment

Latest Posts

Popular Posts