Both "Server" and "Response" are objects of ASP.Net. Both Response.Redirect and Server.Transfer are used for the same purpose of transferring a user from one web page to another web page. Despite the similarity, there are some differences between these two objects.
Let's understand both Response.Redirect and Server.Transfer and know the differences between the two of these.
Both methods have the same syntax as follows:
Difference Between Response.Redirect and Server.Transfer
- Response.Redirect redirects the page request to the HTML pages on our server or it can send it to another web server too.
- It updates the address bar when it redirects to a new page and you can click back also.
- Query string and Form Variables are not preserved from the original request.
- You can bookmark the redirected page.
- It allows you to see the new redirected URL in the Web Browser.
- It just sends a message HTTP 302 to the browser.
- Repsonse.Redirect causes additional roundtrips to the server on each request.
- Server.Transfer redirects the web page request to another .aspx page on the same server.
- Unlike Response.Redirect, it does not update the address bar so you can't click back.
- It optionally preserves the Quesry String and Form Variables.
- You cannot bookmark the new redirected web page.
- It doesn't show the redirected URL in the browser.
- The Web Browser doesn't get to know anything when Server.Transfer happens. The server returns the content of another page when the browser requests a page.
- Server.Transfer doesn't cause roundtrips and preserves server resources of the server.
I hope this article helped you understand the difference between these two methods of ASP.Net. I tried to explain both of these Response.Redirect and Server.Transfer.