Labels

Tuesday, June 12, 2007

How Response.Redirect requies two server trips - Drawback

http://www.devx.com/dotnet/Article/33835/1954?pf=true

The Response.Redirect Method-


The Response.Redirect method is by far the simplest method of redirecting processing from a source page to a different destination or target page in the same or even across different applications. When the web server receives a request for redirection, it sends a response header [
302 Object Moved] to the client that causes the client to send a new request back to the server. In other words, a redirect causes two request/response cycles: one for the original and one for the new redirected request.

The Server.Transfer Method


Instead of relying on the client to make a request to a new page, Server.Transfer is a server-side redirection technique that simply changes the code's "focus" on the web server to a new page. Server.Transfer is far more efficient than Response.Redirect when the target page resides on the same web server, because it avoids the extra roundtrip and uses only server resources for the redirection

Response.Redirect vs. Server.Transfer


Because Response.Redirect requires an extra round trip, you should avoid it for high-volume web sites due to associated performance and scalability issues. However, Response
.Redirect is the only technique that you can use to redirect from one web server to another. In contrast, Server.Transfer is more efficient, but can transfer execution only to a different web page on the same server. In essence, you'd use Server.Transfer to eliminate unnecessary roundtrips when both the source and the target web page reside on the same server (they can be in different ASP.NET applications on that server), and use Response.Redirect when you need to redirect to a different server.

Cross-page Postbacks

Tip - Note that when the target page accesses the PreviousPage property to retrieve the control values of the source page, the ASP.NET runtime loads and executes the source page. That fires the ProcessChildRequest event handler. Moreover, it also fires the Page_Init, Page_Load and any other source page button click events.

So that you can avoid doing all that work accidentally, it's best to check the IsCrossPostBack Boolean property to determine whether a cross-page postback has actually occurred.

Thanks & Regards,

Arun Manglick

SMTS || Microsoft Technology Practice || Bridgestone - Tyre Link || Persistent Systems || 3023-6258

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Pvt. Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Pvt. Ltd. does not accept any liability for virus infected mails.

1 comment:

  1. Summary -

    When the web server receives a request for redirection using Response.Redirect(''), server sends a response header [HTTP redirection header “302 Object Moved”] to the client.
    This causes the client to send a new request back to the server. In other words, it causes the browser/client to load the target/new page from the new location instead from the one it originally requested.
    Hence a redirect causes two request/response cycles: one for the original and one for the new redirected request.

    Regards,
    Arun

    ReplyDelete