ASP Developer Network - Brought to you by Steve Radich and BitShop, Inc. - http://www.bitshop.com

Menu [hide]

ASPFAQDiffRedirectTransfer

What's the difference between Server.Transfer and Response.Redirect print
similar comment
What's the difference between Server.Transfer and Response.Redirect? Can I use either? Should I use one or the other?

The difference goes back to IIS 4 / IIS 5, don’t recall which and classic ASP.

At that time to run a page, then continue with another action in a different page you had a few choices:
1) Include the page, most likely this didn't work easily due to order of page rendering, etc. potential duplicate subroutine names, conficts, etc.
2) Redirect the browser, which sent back the header for the browser to reload a different url for the user to see. This works as if the user went to a page, then clicked the link to follow to the next page (which happens automatically when you do a response.redirect).

The concept of transferring the user on the server was new at that time. The goal was to be able to move to the next page WITHOUT the client (or their browser) having to do any work (reduced network traffic, maintain the original url, etc.).

You also have Server.Execute to consider in this mix.

Sometimes this is "the same" to the programmer / webmaster, other times it may not be.

Perhaps you want to render a header on a page or something like that, then continue executing another page - This can be done easily with server.transfer - Where response.redirect would start a new page, and couldn't easily accomplish this goal.

Today you could probably substitute server.transfer in most cases, you could clear the response output before the transfer and things would work, at least in what is displayed, just like a response.write.

One difference I can think of is if the user tries to bookmark or refresh they will have the old url, and again be server.transferred. This may be preferred on not desired depending on your circumstances - For example if you were trying to track something that happens once a server.transfer may not meet your goal, where a response.redirect the user is on the other url and if they refresh they will still be on the other url.

I hope this helps explain the difference some - It can be confusing. Please write to suggest@aspdeveloper.net with any better examples of when it would be appropriate, versus inappropriate to use either method - This may help clarify things for others.


Steve Radich - http://www.aspdeveloper.net / http://www.virtualserverfaq.com
BitShop, Inc. - Development, Training, Hosting, Troubleshooting - http://www.bitshop.com

Created by: steveradich last modification: Sunday 02 of July, 2006 [06:16:49 UTC] by steveradich



Search
in:
Our Sponsors
FREE .Net 2.0 Tutorials Available Now
http://www.aspdeveloper.net
FREE .Net 2.0 Tutorials Available Now
http://www.aspdeveloper.net
Virtual Server 2005 Info Here!
http://www.aspdeveloper.net
Quality Business Internet Technology Shop - http://www.bitshop.com Sponsor of site and hosting
Want to contribute to aspdeveloper.net? Contact us! suggest@aspdeveloper.net
rss Wiki rss Blogs rss Articles rss Image galleries rss File galleries rss Forums rss Maps rss Directories
ASP Developer Network (since 1996) - Brought to you by Steve Radich and BitShop, Inc. - http://www.bitshop.com
Copyright © 1997-2005 by BitShop, Inc. All Rights Reserved.
No content may be reproduced in any form without written permission from BitShop, Inc.
We will be honored to assist with reproduction rights on our material if you contact us.
We also can provide print articles for your magazine, private training seminars at your site, and conference presentations.

Thank you for visiting. Please bookmark our site if you found it useful!
If you wish to make a donation it will help further the development of these free resources: