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

Answer Posted / skmdali786

This is one of the favorite questions in ASP.NET Interviews.
Every interviewer would like to know from the .NET candidate
two things, how they differ technically and which scenarios
should we use them.

Technical difference :- In Response.Redirect the following
steps happen :-

1 - Client browser sends a signal to the server that he
wants to go to xyz.aspx.
2 - Server responds back to the browser about the location
of xyz.aspx and tells the client to go to that location.
3- Client gets the response and redirects to xyz.aspx.

In server.transfer the the following step happens :-

1 - Client browser sends a signal to the server that he
wants to go to xyz.aspx.
2 - Server redirects to xyz.aspx and send the output to the
client.

In other words in response.redirect there is a round trip
while in server.transfer there are no round trips.

The next question what interviewer will ask is so does that
mean we should always use server.trasfer and
response.redirect is never needed.

Both of the are useful under different scenarios.
Response.redirect is good when we want to go cross domains ,
in other words you want to redirect from www.questpond.com
to www.microsoft.com. Server.trasfer do not work when you go
cross domains.

Is This Answer Correct ?    8 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is faster union or union all?

762


Is LINQ performance wise better or using sqlcommand?

4626


Tell me the code snippet to show how we can return 404 errors from HttpError?

1028


Where are session variables stored?

717


How long do session variables last?

717


What are the different types of Caching techniques in ASP.NET?

776


How do u deploy ur project?

2409


What is a proxy in web service?

774


What is bson in web api?

804


What is difference between session and cookies in asp net?

733


What are validator? How do you disable them?

795


What are client activated objects and server activated objects?

717


Mention the execution process for managed code?

735


How does a content page differ from a master page?

714


What is the use of dispose method?

754