Which one is better, Server.Transfer
or Response.Redirect
? I am looking for some explanation for this.

- 12,319
- 15
- 70
- 118

- 3,469
- 7
- 35
- 42
-
2These links [MSDN Discussion](http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/84406666-13d3-49e3-8f35-7f6f065a7d31) and [This one](http://techahead.wordpress.com/2007/10/14/aspnet-servertransfer-vs-responseredirect/) may be helpful. – Sanjeevakumar Hiremath Mar 01 '11 at 07:07
-
@Vikas avoid server.transfer, is not better, and you going to discover that on your development. For example the post back is not working on server.transfer – Aristos Mar 21 '11 at 02:59
-
@Aristos as far as post back is concern you should [read this one](http://msdn.microsoft.com/en-us/library/ms178139.aspx) for a solution of it, in case of server.transfer. – Student Mar 21 '11 at 12:47
-
My dear friend, in a real world web pages you can not do all that all the time. In the pages some times you have to move front and back on a 5 or 10 different page logistic steps... With server transfer you just can not do that. As I say you and you going to find it out by the time, the Redirect is the most usable. – Aristos Mar 21 '11 at 21:20
-
possible duplicate of [Server.Transfer VS Response.Rewrite](http://stackoverflow.com/questions/8867956/server-transfer-vs-response-rewrite) – Jan 15 '12 at 07:04
2 Answers
They have different functions. Definition of better depends on what you are trying to do.
Response.Redirect tells the client to visit a new address, which can be anywhere.
Server.Transfer forwards the request (optionally preserving the query string) to another page on the same server.
If your criterion is cutting unnecessary overhead given that the new page is on the same server, Server.Transfer is the method you want.

- 2,074
- 1
- 15
- 12
-
1+1. Only person actually pointing out they have different functions and not jumping to half argumented bad conclusions. – TomTom Mar 01 '11 at 07:29
It depends on your reqiremnts.
Suppose if you are on page1.aspx and wants to go to page2.aspx
Response.Redirect scenario
page1.aspx calls Response.Redirect("page2.aspx",false); which sends a 302 redirect header down to the client browser, telling it that the requested (page1.aspx) has moved to page2.aspx, and the web application terminates. The client browser then sends a request to the webserver for page2.aspx. IIS tells asp_wp.exe to process the request. asp_wp.exe (after checking authentication and doing all the other setup stuff it needs to do when a new request comes in) instantiates the appropriate class for page2.aspx, processes the request, sends the result to the browser, and shuts down. In this case there is a roundtrip to the server.
Server.Transfer scenario
page1.aspx calls Server.Transfer("page2.aspx");. ASP.NET instantiates the appropriate class for page2.aspx, processes the request, sends the result to the browser, and shuts down.
Note that Server.Transfer cuts the load on the client and the server.
Server.Transfer is easier to code for, too, since you maintain your state. Information can be passed through the HTTP Context object between the pages, eliminating the need to pass information in the querystring or reload it from the database.
Some limitations of Server.Transfer
It can only work for same domain pages (on same server)
It bypasses any authentication on the page you transfer to
Now you can take decision yourself which one is better according to your requirements.

- 3,469
- 7
- 35
- 42
-
1-1. You are ignorin the positive sides of server.transfer and the implications on seo techniques. As a result, youcome to wrong conclusions. Dangerous level of half-knowledge. – TomTom Mar 01 '11 at 07:29
-
@TomTom it seems that you was in a hurry to votedown that's you not read my answer correctly. here I am giving scenario and explanation and telling limitations. – Student Mar 01 '11 at 07:36
-
@Student -1 Server transfer have many limitations and must used only on rare cases. Profane you do not have use it in real life. Post back is not working for example. The one is not better than the other, they just used for different purpose - but the redirect is used 99% of the cases. – Aristos Mar 21 '11 at 03:02
-
@Aristos I have update my answer. Any way I have never said that Server.Transfer has no limitations. I have mentioned some limitations of it. – Student Mar 21 '11 at 12:22
-
@Student Is not only the limitation, let me say one more example, after the server transfer, iis load the new page and show a new different page, if you make any post back or move, then the first page is loaded and RUN AGAIN, and then must again send it to the same second page if you can know again where to send it. I do not know if I am understandable, but you find this issues when you really make use of them. – Aristos Mar 21 '11 at 21:27