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 the reason why the javascript validation not run on the asp.net button but run successfully on the html button?

578


What is the request flow used for asp.net mvc framework? : asp.net mvc

535


How to make paging concepts in datagrid in ASP.NET?

556


How we can force all the validation controls to run?

527


Explain the features that make asp.net more used framework? : asp.net mvc

487






Which method is used to perform all validation at the page level?

540


Explain the benefits of viewstate?

590


What is inproc and outproc?

525


Why viewstate is used in asp.net?

511


What is custom events?

573


What are the advantages and limitations of query string?

574


Explain the difference between webfarm and webgardens in .net?

548


what is silver light when will we use silver light,

1445


I am trying to implement sorting facility from client side code in GridView Control. So how can I fill up an Array inside client side code (using JavaScript), i want to assign my DataSet object declared and filled up on Server side(in code behind) to the array (on client side)

1495


What are the different types of validation controls provided in ASP.NET?

670