Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Server.Transfer effectively

How to use Server.Transfer("default.aspx") for better performance for navigating within the website. When I use this, it is not changing the url in the address bar. How can I achieve new url by server.transfer. Or (If Not) how can I gain performance with Response.Redirect("default.aspx").

like image 778
Rajaram Shelar Avatar asked Jan 15 '23 23:01

Rajaram Shelar


1 Answers

You need to understand the difference between Response.Redirect("page.aspx") and Server.Transfer("page.aspx")

Server.Transfer:

  • It does not change the URL, so it is not for debugging purposes because you are not certain which page is running down in the browser since URL might not changed in more than one Server.Transfer statements.

  • It posts data from all controls on the Form on to the next page, from where you can access them using Request.Form["myTextBox"]

  • It only works within the same domain, it will not redirect outside the current domain name.

  • It does not cost a round trip on server back from browser, so it is faster as compared to Response.Redirect.

Use your best judgement when to use Response.Redirect and when to use Server.Transfer. I would only recommend using 'Server.Transfer' if you want to send Form Controls' data from one page to other, otherwise it will give you a debugging nightmare.

like image 121
raheel khokhar Avatar answered Jan 19 '23 00:01

raheel khokhar