There are several methods to send data from one page to
another page.
·
Response.Redirect
To perform client side redirection in ASP.NET, users can
call Response.Redirect and pass the URL. When Response.Redirect is called, the
server sends a command back to the browser telling it to request the page
redirected to it. An extra roundtrip happens, which hit the performance. We
can send information from the source page by using a query string. There is a
limitation on the length of a query string; it cannot be used to pass large
amounts of data over the wire.
·
Cookies
We can store data using cookies. Cookies are created on the
server side, but saved on the client side. Cookies can be deleted from client
side.
·
Session Variables :
We can store the source page information in the session and
retrieve it from the target page. However, this requires saving the information
on the server so the server memory load can be increased.
·
Server.Transfer
To perform server-side redirection, users can use
Server.Transfer. As the execution is transferred on the server,
Server.Transfer does not require the client to request another page. In
Server.Transfer, by using HttpContext we can access the source page’s items
collection in target page. The drawback of using this method is that the
browser does not know that a different page was returned to it. It displays
the first page's URL in the browser's address bar. This can confuse the user
and cause problems if the user tries to bookmark the page. Transfer is not
recommended since the operations typically flow through several different
pages.
·
Others
We can use cache to store data and that can be accessed
anywhere from the application. However, this is recommended only for data that
is modified infrequently, but used often. We can use application variable for
some specific purpose, for example, to maintain hit counter in the page.