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

Explain what the contents of cookie?

590


What are the parts of an http response?

498


How do cookies work?

594


What's the ASP.Net Application life cycle?

566


What is difference between View State and Hidden Field in ASP.NET?

659






how to transfer the file from client to server using asp.net

592


Explain the asp.net session state modes.

616


What is form method?

497


Explain the difference between server.transfer and response.redirect? Why would I choose one over the other?

541


Explain a program using razor view engine to create a simple application? : asp.net mvc

497


Using code explain Configuration Management

1408


Why is global asax is used?

614


What is request and response in asp.net?

511


What symbol would you use to denote, the start of a code block in aspx views?

573


What is the life cycle of an asp.net page?

526