Request.Redirect vs. Server.Transfer
Category: DotNet
I often forget which one of these to use in what scenario:
Server.Transfer("~/admin/someurl.aspx");
Request.Redirect("/control/anotherurl.aspx");
In essence, they do the same thing, simply take you to the page you specify as a parameter. But they do this in different ways.
Request.Redirect actually sends a 304 and loads the url as if you typed it in and hit enter. You should use this when you need to pass querystrings in the redirection url. The url at the top will actually change, so any previous querystrings will not stick. Also, you cannot use the PreviousPage c sharp command to have access to variables in the page doing the redirection.
Server.Transfer on the other hand does not hit the client. The url in you browser window will not change although you will be in a different page. This means previous querystring will stick. This also means you shouldn't use it to pass querystrings in the redirection url. The cool thing about it is that you can use PreviousPage on the page you transferred to so as to get access to variables in the transferred from page.
In load balanced scenarios, Server.Transfer will actually keep the object and the client connected to the same sever. If you use Request.Redirect the client could end up requesting from another server. Depending on what it is you are trying to do, keep this in mind.