Sunday, 29 November 2015

Difference between Response.Redirect and Server.Transfer

Standard
Response.Redirect :

  1.   It sends an HTTP request to the browser,then the browser sends the request to the server,then the server deliver a response to the web browser.
  2. This method can be used for both .aspx and Html pages.
  3. This method can be used to redirect a user to an external website.
  4. While using Response.Redirect method,the previous page is removed from server memory and load a new page in memory.
  5. Address of the URL will be changed along with the content.
  6. This method also update history of the browser 


Server.Transfer :

  1. This method sends request directly to the web server and web server delivers the response to the browser.
  2. By using this method we get same URL but with different  content that means web page URL in the address bar will not changed.
  3. It can only used for .aspx page and is specific to ASP.NET
  4. While using Server.Transfer the previous page also exits in server memory.
  5. It can be used only on sites running on the same server. we can not use to redirect the user to a page running on a different server.

Syntax for Both :

Response.Redirect ("Default.aspx");
Server.Transfer("Default.aspx");

0 comments:

Post a Comment