X



Home>Tutorial>

All About ASP.Net Response.Redirect vs Server.Transfer

Nuelson Penuel Saturday, August 29, 2020 ASP.Net

Introduction

Response.Redirect and Server.Transfer are objects of ASP.NET. These two objects serves the same functions but carry out their operations in different ways. When any of these two objects is used, a redirection will occur meaning the client will be transferred from one web page to another. To learn about other means of page redirection, check this post

Server.Transfer

Server.Transfer is used to navigate to other pages or sites running on the same web server.

Server.Transfer Syntax

Syntax:
Server.Transfer(path)
Where path refers to the location of the file to which control should be transfered

Response.Redirect

The Response.Redirect() method is used to redirect a user from one page to another and also letting the user know that you have been redirected from your current page to another.

Response.Redirect Syntax

It has the following syntax;
Response.Redirect(path)
Where path refers to the destination file that is requested by the client. If you could noticed, both are used for navigating from one web page to another. However, there are noticeable differences between these two techniques:

Differences Between Response.Redirect and Server.Transfer

  1. Response.Redirect() do not reduce server request hence do not conserve server resources. While Server.Transfer() reduces the server request and conserves server resources.
  2. Response.Redirect() can be used to redirect the users to another web-page on the same server or external server. While Server.Transfer can also be used to redirect users to another web page but only on the same server.
  3. Response.Redirect always change the address bar from the current page to the destination page. While Server.Transfer keeps the address of the current web page and still transfer user to the destination page.
  4. When Response.Redirect() is used, form variables are are not transferred. While Server.Transfer() method has a second parameter known as preserveForm. If this is set to True, the existing query string and form variables will be available to the transferred page. Server.Transfer(“mypage2.aspx”, True)

| | Views(1053)

See Demo | Download File


Add your comment. Indicate code using code tag


Words: 0 | Chars: 0 | Reading Duration: 0



Images Attachment




Emmason Integratded Services(2017-2024)
All Rights Reserved
Designed and Maintained By Emmason Integrated Services