Showing posts with label Server. Show all posts
Showing posts with label Server. Show all posts

Thursday, May 3, 2012

ASP.Net Interview questions: - Mention differences between ‘Server.Transfer’ and ‘response.Redirect’?

Following are the major differences between them:-

‘Response. Redirect’ sends message to the browser saying it to move to some different page, while server. Transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in ‘server. Transfer’ there is no round trip while ‘response. Redirect’ has a round trip and hence puts a load on server.

Using ‘Server. Transfer’ you cannot redirect to a different from the server itself. Example if your server is www.yahoo.com you cannot use server. Transfer to move to www.microsoft.com but yes, you can move to www.yahoo.com/travels, i.e. with in websites. Cross server redirect is possible only by using Response. Redirect.

With ‘server. Transfer’ you can preserve your information. It has a parameter called as “preserveForm”.Therefore, the existing query string etc. will be able in the calling page.

If you are navigating within the same website use “Server. Transfer” or else go for “response.Redirect ()”

See the following video on ASP.NET4.0: -



Click for more ASP.NET interview questions

Regards,

Visit for more Authors’ blog on ASP.NET interview questions

Tuesday, February 1, 2011

Response.redirect and server.transfer ( .NET Interview questions)

Response.redirect and server.transfer (
.NET Interview questions)



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 http://www.questpond.com/ to http://www.microsoft.com/. Server.trasfer do not work when you go cross domains.
22 top important .NET interview questions