.Net Interview Questions and Answers

Search:

ASP.NET interview questions with answers: - 'Server.Transfer' VS 'response.Redirect' ?

By : Shiv Prasad Koirala | Jul 30th, 2013 | Views : 12622 | Comments : 0 Bookmark and Share

Both "response.redirect" and "server.transfer" helps to navigate from one page to other page.

 

                                            

 

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".

                          

 

 

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

 

     1.   Client sends a request to the server to navigate 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.

 

                                               

 

So when to use "Server.Transfer" and when to use "Response.Redirect" ?

 

Use "Server.Transfer" when you want to navigate pages which resides on the same server , use 'Response.Redirect' when you want to navigate between pages which resides on different server.

 

                        

 

Below is a nice video which explains "Response.Redirect" and "Server.Transfer" in a practical and demonstrative way.

 

 

We are thankful to www.questpond.com for providing us ASP.NET Interview questions with answers on a daily basis.

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi