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


Response.Redirect

  • Response.Redirect simply used to send user from one page to another page.
  • In this case URL changed in the browser.
  • it can also navigate to outside pages of the application.
  • Syntax : Response.Redirect(“URL of another page”);
  • It Can’t access previous page control on new page.
  • PreviousPage.FindControl() is not available on new page.
  • It involves extra round trip to the server.

Server.Transfer

  • Server.Transfer is used to transfer control from one page to another page. Control execute code on another page but control doesn’t return back to previous page.
  • In this case URL doesn’t change in the browser.
  • it can not navigate to outside pages of the application.
  • Syntax : Server.Transfer(“URL of another page”);
  • It Can access previous page control on new page.
  • PreviousPage.FindControl() is available on new page.
  • It conserves server resources by avoiding that extra round-trip.

Server.Execute

  • Server.Execute is used to transfer control from one page to another page. Control execute code on another page and return back to previous page.
  • In this case URL doesn’t change in the browser.
  • it can not navigate to outside pages of the application.
  • Syntax : Server.Execute(“URL of another page”);
  • It Can access previous page control on new page.
  • PreviousPage.FindControl() is available on new page.
  • It conserves server resources by avoiding that extra round-trip.