Response.Redirect Vs Server.Transfer

Posted by Venkat | Labels:

1) Response.Redirect(“newpage.aspx”)

In some case , if i use like this it shows ThreadAborExecution error, when the above line execute it Calls the Response.End() and it's Response.End() that calls Thread.Abort() this makes the error.

Response.Redirect(“newpage.aspx”,false) // whereas the second parameter is false / true

Ref: http://www.c6software.com/articles/ThreadAbortException.aspx

and Server.Transfer(“newpage.aspx”)

2) Server.Transfer -  redirects the client with in the same application ie, from one ASP page to other ASP page with in the application. This will not update the history.

Response.Redirect: - This redirects the client to the other URL ie, from one ASP page to other applications page. This will update the history.

3) Response.Redirect involves a roundtrip to the server

whereas Server.Transfer conserves server resources by avoiding the roundtrip. It just changes the focus of the webserver to a different page and transfers the page processing to a different page.

4) Roundtrip means in case of Response.Redirect it first sends the request for the new page to the browser then browser sends the request for the new page to the webserver then after your page changes.

But in case of Server.Transfer it directly communicate with the server to change the page hence it saves a roundtrip in the whole process.

5) If you are using Server.Transfer then you can directly access the values, controls and properties of the previous page - using Context.Item collections

- which you can’t do with Response.Redirect.

6) Response.Redirect changes the URL in the browser’s address bar. So they can be bookmarked.

Whereas Server.Transfer retains the original URL in the browser’s address bar. It just replaces the contents of the previous page with the new one.

7) Response.Redirect can be used to redirect a user to an external websites.
Ex: www.Google.com,www.hyderabadtechies.info..,

Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.

PayOffers.in