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


1 comment:

asd said...


Post a Comment

Latest Posts

Popular Posts