ASP.NET interview questions: – How ‘Server.Transfer’ differs from ‘response.Redirect’ and when to use “Server.Transfer” or “Response.Redirect”?

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

p1

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 outputHTML 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”.

p2

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.

p3

Uses of “Server.Transfer” and “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.

p4

Also click and see the following ASP.NET interview questions video on Response.Redirect (False VS True).

Advertisements

About c# and .NET Interview questions

This blog is for developers who want to crack .NET and C# interviews. It has all tips and tricks needed to crack .NET interviews , C# interview , SQL Server interview , Java interview , WCF Interview , Silverlight interview , WPF interview , LINQ interview , Entity framework Interview. Do not forget to watch our Learn step by step video series. Learn MVC in 16 hours:- https://www.youtube.com/watch?v=Lp7nSImO5vk Learn AngularJS Step by Step:- https://www.youtube.com/watch?v=0kmdjqgO9IY Learn Design Pattern in 8 hours:- https://www.youtube.com/watch?v=YDobmucohqk Learn C# and .NET in 60 days:- https://www.youtube.com/watch?v=yh2SrzCkNQA Learn MSBI in 32 hours:- https://www.youtube.com/watch?v=mGPJx3ocFgg Learn SharePoint Step by Step in 8 hours:- https://youtu.be/C2fW76SwJNU
This entry was posted in Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s