Response.Redirect and Server.Transfer difference in asp.net



Response.Redirect() Vs Server.Transfer()

Both Response and Server are object of ASP.Net and both are used to redirect a user from one page to another page. Response.Redirect and Server.Transfer both method are used to redirect user from one page to another page.

Syntax

  • Response.Redirect(“nextpage.aspx”);
  • Server.Transfer(“nextpage.aspx”);

Response.Redirect()

  • We can use response.redirect to send user to same server or to some other web server.
  • Response.Redirect() can be used to redirect to an external websites.
  • Can finish the whole Round trip and then after send user to another page.
  • Can use Session() object with Response.Redirect in ASP.Net.
  • Can not use Context object with Response.Redirect because context object value will be null while page goes to server.
  • Resonse.redirect() can be used both for aspx and html pages.

    Response.Redirect(“meera.aspx”);
    Response.Redirect(“meera.html”);

  • In Response.Redirect the browser’s history is updated.
  • Response.Redirect() changes the URL in the browser’s address bar.

 

Server.Transfer()

  • We can use Server.Transfer to send user to same server web form, we can not send user to other server.
  • we can use Server.Transfer() to redirect to only inside the same website.
  • Can use Context with Server.Transfer to send value from one form to another form.
  • Server.transfer is only used for aspx pages it will not work for html pages.

    Server.Transfer(“meera.aspx”);

  • In Server.Transfer the browser’s history is not updated.
  • Server.Transfer() does not change URL in the browser’s address bar.
(Visited 151 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *