=> 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 can not redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect.
=> With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page.
=> Use server.transfer to navigate within website. And use Response.redirect to redirect to another website.
Response.Redirect
Server.Transfer
=> Using Server.Transfer you can not redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect.
=> With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page.
=> Use server.transfer to navigate within website. And use Response.redirect to redirect to another website.
using System;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("SecondPage.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
Server.Transfer("SecondPage.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.yahoo.com");
}
protected void Button4_Click(object sender, EventArgs e)
{
Server.Transfer("http://www.yahoo.com");
}
}
Response.Redirect
- The page is redirected permanently.
- Used to navigate within the same application as well as navigating from one application to another application.
- The URL is changed because the processing of the second page is done on the second page, not on the first page from where we redirected.
- We can bookmark the page because the full address is shown in a browser URL.
- An extra round trip happens to the server.
- It is used in HTML, ASP and ASP.Net pages to navigate from one page to another.
Server.Transfer
- The Page is not redirected permanently.
- Used to navigate within the same application, not outside of an application.
- The URL is changed because the processing of the second page is done on the same page, without navigating on the second page.
- We cannot bookmark the page because the full address is not shown in a browser URL.
- An extra round trip does not happen to the server; because of this it saves server resources.
- It is only used to navigate within an ASP or ASP.Net page, not within HTML pages.
0 comments:
Post a Comment