top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How many way to Page Redirection Approaches in ASP.NET?

+1 vote
311 views
How many way to Page Redirection Approaches in ASP.NET?
posted Feb 8, 2016 by Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Response.Redirect

Response.Redirect is said to be a client side redirection. This technique is implemented by using client browser that means it is handled within the client's browser. When we use this method, by default, it halts the execution of the current page and redirect the user to another URL mentioned in the method. ASP.NET performs redirection in this method by sending 302 response to client's browser. The original request and the redirected request will make two requests to the server. When we use the overloaded version of the method with endResponse Boolean parameter set to false, it will continue execution of the current page at the same time redirecting to another page.

Response.Redirect("http://www.devasp.net")
Response.Redirect("http://www.devasp.net", False)

Server.Transfer

Server.Transfer is said to be a server side redirection. This technique is implemented in the web server that means this method performs redirection by avoiding HTTP requests. When we use this method, the state information for all the built-in objects are included in the transfer. This means that the values assigned in session or application scope to any variables or objects, are maintained. this method sends only one request to the server and eliminates one request instead of sending two requests in case of Response.Redirect. In this method, since the server does not inform the change to the client's browser and the URL does not change in the browser so it can be a little confusing for users.

Server.Transfer("/default.aspx")

Pros and Cons

There are some advantages and disadvantages for both methods and the usage of each method depends on the situation and on your requirements.

Performance of the Server.Transfer method is better than Response.Redirect since Response.Redirect sends two calls to the server as oppose to the Server.Transfer which sends only one.

Server.Transfer method does not interact with the browser so it may possible that it breaks some JavaScript or AJAX functionality.

As I discussed it earlier, Server.Transfer may cause some confusion in user's mind as URL displayed in the browser will not change.

The advantage of Server.Transfer method over Response.Redirect is that Server.Transfer provides some kind of security as we are not showing our data to the user but in case of Response.Redirect we are exposing our data to the user.

answer Feb 8, 2016 by Shivaranjini
...