Content
Every developer goes to an interview for future growth and the interviewer also asks the some basic questions, the developer provides the answer that he reads and studies but sometimes the interviewer changes the basic question in a tricky way, like:
The interviewer might ask "What is the difference between Response.Redirect() and Server.Transfer()?". Then you will rely like:
- Response.Redirect() is useful when we want to go to the page of external websites, where as Server.Transfer() is used for accessing the page of the internal websites or within the same server.
- Response.Redirect() changes the URL but Server.Transfer() doesn't.
And the following line for sure.
- Response.Redirect() takes the round trip where as Server.Transfer() doesn't.
"What does Round Trip mean, can you explain it and how can I see it visually".

Answer: In the case of Response.Redirect(), first send the request to the Browser with "HTTP 302 Found" code then the Browser sends the request to the server and gets the response with "HTTP 200 Ok" from the server.
But if I talk about Server.Transfer() that directly sends the request to the server and gets the response with "HTTP 200 Ok" from the server.
To understand it visually see the following the code:

Open Visual Studio 2015 and select "File" -> "New" -> "WebSite: and fill in the WebSite name as "WebSite1".

After creating the WebSite, I will create 2 Pages named "Page1.aspx" and "Page2.aspx" for re-direction from the first page to the second page.

For the identification, I have added some text on both pages as in the following.
Page1.aspx

Page2.aspx

Now I will use both Response.Redirect() and Server.Transfer() on the "Page_Load" event of "Page1.aspx".
Response.Redirect()
It redirects to "Page2.aspx" from "Page1.aspx".
Code
- public partial class Page1 : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Response.Redirect("Page2.aspx");
- }
- }







Deepak SainiPosted Mar 26, 2015, 3:19 AM
nice
Rupesh SharmaPosted Jan 23, 2015, 12:18 AM
Nice
Arun GuptaPosted Jan 22, 2015, 12:22 AM
Good Explanation.
Vishal JadhavPosted Jan 21, 2015, 11:26 PM
Nice article.
Jitendra KumarPosted Jan 21, 2015, 8:55 AM
Good..
Sahil SharmaPosted Jan 21, 2015, 7:10 AM
nicely explained.
Humayun Kabir MamunPosted Jan 21, 2015, 6:48 AM
Nice...
Rahul BansalPosted Jan 21, 2015, 5:16 AM
Thanks Bhushan
Bhushan GawalePosted Jan 21, 2015, 5:15 AM
Nice article!! In first paragraph Redirect.Redirect() looks a typo, should be Response.Redirect()
Sudheer KumarPosted Jan 21, 2015, 5:11 AM
Nice