Xpode.com        Click here to Print this article.

QuestPond’s interview questions and answers on Server.Transfer and response.Redirect in ASP.NET

What is the difference between ‘Server.Transfer’ and ‘response.Redirect’?

Server.Transfer and response.Redirect are favorite ASP.NET interview questions among the interviewer especially to check ASP.NET fundamentals of the candidate.

Both “response.redirect” and “server.transfer” helps to navigate from one page to other page. Learn one more interview question from interviewer practically when to you use response.redirect or server.transfer.

In “Server.Transfer” following is the sequence of how navigation happens: -

  1. User sends a request to navigate to other page.

  2. Server creates the page object, executes the complete page life cycle and creates the HTML output.

  3. The output HTML response is then sent back to the client browser.

Now let’s says we want to navigate between pages which reside on different servers. Now in this scenario the server cannot create object of that page as the page is located on some other server. On that external server this server has no control. So for external navigation we need to use “Response.Redirect”.

n2

In “Response.Redirect” following is the sequence of events for navigation:-

  1. Client sends a request to the server tonavigate to some other page.

  2. Server sends the request back to the client browser telling him to do it as that page is not located in his server.

  3. Client then sends a HTTP “get” request to the other server for the page and that server creates the page object and sends the response back to the client browser.

Note: - It is possible to use “Response.Redirect” to navigate pages from the same server but then unnecessarily we are making extra round trip to achieve the same.

Learn Server.Transfer VS Response.Redirect in more details using simplified English.



http://
http://www.questpond.com/

Contributed by:
Shivprasad koirala Koirala
I am a Microsoft MVP for ASP/ASP.NET and currently a CEO of a small E-learning company in India. We are very much active in making training videos , writing books and corporate trainings. Do visit my site http://www.questpond.com for .NET, C# , design pattern , WCF , Silverlight , LINQ , ASP.NET , ADO.NET , Sharepoint , UML , SQL Server training and Interview questions and answers

Resourse address on xpode.com
http://xpode.com/xpodehost/Print.aspx?Articleid=775

Click here to go on website