473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

What is the difference between server.transfer and response.redirect

I am confused about the difference between "server.transfer" and "response.redirect". Can anyone clarify the differences for me?
Nov 12 '09 #1

✓ answered by Frinavale

There are some major differences between these to methods.

I think the major difference is that Response.Redirect sends an HTML Status Code to the web browser indicating that the browser should redirect to the other page.

The Server.Transfer doesn't tell the browser to redirect the user, it changes the user to the new page on the server. This means that you cannot use Server.Transfer to send the person to a web page that isn't on the server.

When you use Server.Transfer, the URL in the browser's address bar doesn't change because the user was moved to the new page on the server.

Also, when you use Server.Transfer it could be configured in such a way that all of the variables and controls that were available on the first page are made available to the page that that the server transferred to. (To do this you specify that preserveForm = true...this is the second parameter of the Server.Transfer method)

For example, say you have DefaultForm1.aspx which has TextBox1 on it....now you use Server.Transfer to DefaultForm2.aspx. DefaultForm2.aspx will have access to TextBox1 that is located in DefaultForm1.aspx.

This can be very confusing and can lead to some major problems with debugging....but then again it can be very helpful if you use it properly.


Transferring to another page using Server.Transfer conserves server resources because there is less traffic. As apposed to Response.Redirect, which sends a response to the browser telling it make a new request to the next web page, Server.Transfer changes the "focus" on the Web server to the next web page and transfers the request. This means you don't get quite as many HTTP requests coming through.

When you use Server.Transfer the URL in the web browser isn't pointing to the actual page that the user is viewing. This means that things like relative links/image paths may not work if you transfer to a page from a different directory.

I tried using Server.Transfer for a wizard-style registration system once and I ended up experiencing so many problems with it that I chose to go back to using Response.Redirect (and then I did away with separate web pages and just used User Controls on 1 web page so I didn't have to use Response.Redirect either).

I know that Server.Transfer sounds like the best way to do things (if you aren't directing people to a different website). But, if I were you I'd do more research in to the topic. I'd give Server.Transfer a try and see what all of it's quirks are and then make a decision on which to use.

You always learn best from experiencing things...and the only way to experience is to try it.

-Frinny

3 2640
Frinavale
9,735 Expert Mod 8TB
There are some major differences between these to methods.

I think the major difference is that Response.Redirect sends an HTML Status Code to the web browser indicating that the browser should redirect to the other page.

The Server.Transfer doesn't tell the browser to redirect the user, it changes the user to the new page on the server. This means that you cannot use Server.Transfer to send the person to a web page that isn't on the server.

When you use Server.Transfer, the URL in the browser's address bar doesn't change because the user was moved to the new page on the server.

Also, when you use Server.Transfer it could be configured in such a way that all of the variables and controls that were available on the first page are made available to the page that that the server transferred to. (To do this you specify that preserveForm = true...this is the second parameter of the Server.Transfer method)

For example, say you have DefaultForm1.aspx which has TextBox1 on it....now you use Server.Transfer to DefaultForm2.aspx. DefaultForm2.aspx will have access to TextBox1 that is located in DefaultForm1.aspx.

This can be very confusing and can lead to some major problems with debugging....but then again it can be very helpful if you use it properly.


Transferring to another page using Server.Transfer conserves server resources because there is less traffic. As apposed to Response.Redirect, which sends a response to the browser telling it make a new request to the next web page, Server.Transfer changes the "focus" on the Web server to the next web page and transfers the request. This means you don't get quite as many HTTP requests coming through.

When you use Server.Transfer the URL in the web browser isn't pointing to the actual page that the user is viewing. This means that things like relative links/image paths may not work if you transfer to a page from a different directory.

I tried using Server.Transfer for a wizard-style registration system once and I ended up experiencing so many problems with it that I chose to go back to using Response.Redirect (and then I did away with separate web pages and just used User Controls on 1 web page so I didn't have to use Response.Redirect either).

I know that Server.Transfer sounds like the best way to do things (if you aren't directing people to a different website). But, if I were you I'd do more research in to the topic. I'd give Server.Transfer a try and see what all of it's quirks are and then make a decision on which to use.

You always learn best from experiencing things...and the only way to experience is to try it.

-Frinny
Nov 12 '09 #2
thanks for reply. . .
Nov 14 '09 #3
Frinavale
9,735 Expert Mod 8TB
Any time :)

-Frinny
Nov 14 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Kevin Vogler | last post by:
I have a subdirectory with it's own images folder. All the image paths in the pages in the sub directory are "image/image.jpg" When I Response.Redirect to a page in the subdirectory the images...
6
by: \A_Michigan_User\ | last post by:
Ok, I give up... why do 1-4 work fine... but 5-6 give "can't find" errors? 1. Client-side VBscript code: call navigate("\\209.11.22.33\MyDir") 2. Client-side VBscript code: location.href...
4
by: Harsh Thakur | last post by:
Hi, I'd like to know the performance related differences between Response.Redirect and Server.Transfer. I'd like to redirect the user to a different page. I can either do a...
3
by: Alan Silver | last post by:
Hello, Sorry if this is a stupid question, but I can't really see much difference between these tow methods according to the scant info in the SDK. Could anyone enlighten me? TIA -- Alan...
4
by: batista | last post by:
Hello All, I want to know the Difference Between Server.Transfer() And Response.Redirect()?
9
by: odwrotnie | last post by:
Hi, what is the difference between Response.Redirect("Stop.aspx"); and Server.Transfer("Stop.aspx"); ? -- Best regards,
20
by: Simon Says | last post by:
Hi, I've a login page in which after authenticating it via the Oracle DB, I will stored the user information into the Session. However, when the Session timeout occurs, all of the user...
1
by: sajithamol | last post by:
What is the difference between Server.Transfer and Response.Redirect?
3
by: jasonheath.net | last post by:
I apologize in advance for the length of this post. I wanted to get as much detail as possible in here. We have 1 web app that contains the functionality to do some single sign-on logic. The...
2
by: Dale Harris | last post by:
Hi, I was wondering, is there a difference between Server.Transfer and Response.Redirect? They seem to do the same thing. Or am I mistaken? TIA ** Posted from http://www.teranews.com **
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.