- To redirect the page from the same as well as a different web server.
- don't care about causing additional round trips to the server on each request.
- do not need to preserve the Query String and Form Variables from the original request.
- want our users to be able to see the new redirected URL, where the page is redirected.
- want to bookmark the page.
Server.Transfer navigates the pages within the same application or within the same server, the page is still in memory that can read the values directly from page2 on page1, in other words by using server.Transfer the page is not redirected permanently.
The suitable uses are:
- to transfer the current page request to another .aspx page on the same server.
- to preserve server resources and avoid the unnecessary round trips to the server.
- to preserve the Query String and Form Variables.
- don't need to show the real URL of where we redirected the request in the user's Web Browser.
- don’t want to bookmark the pages.
- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New WebSite" - "C#" - "Empty Web Site" (to avoid adding a master page).
- Provide the Project name such as "ResponseVsServer" or another as you wish and specify the location.
- Then right-click on Solution Explorer then select "Add New Item" - "Default.aspx" page (two web pages).
Now write the some code to redirect the pages as:
- The page is redirected permanently.
- Used to navigate within the same application as well as navigating from one application to another application.
- The URL is changed because the processing of the second page is done on the second page, not on the first page from where we redirected.
- We can bookmark the page because the full address is shown in a browser URL.
- An extra round trip happens to the server.
- It is used in HTML, ASP and ASP.Net pages to navigate from one page to another.
- The Page is not redirected permanently.
- Used to navigate within the same application, not outside of an application.
- The URL is changed because the processing of the second page is done on the same page, without navigating on the second page.
- We cannot bookmark the page because the full address is not shown in a browser URL.
- An extra round trip does not happen to the server; because of this it saves server resources.
- It is only used to navigate within an ASP or ASP.Net page, not within HTML pages.