Also checkout my blogs on: PMP | C# | SQL | Personal

  Tuesday, January 10, 2006

Redirect to a different page


  • The browser receives request from the webserver and browser does this. The user will not be able to find out the difference, except that it takes long to see something in the browser window. Basically the sends a http status code of 302 (object moved), which direct browser to look into the header for the new url.
  • Since the browser is directed to send another request to the new url, unnessary load on the server
  • Can be used to transfer to external pages that are not running on the same server.


  • If bln == true, all the form variables will also be transferred to the new url.
  • Transfer to the new page happens on the server side completely and browser is not involved and will not be aware.
  • For the above reason, the address in the browser doesn’t change
  • Can not be used to transfer to aspx pages running on the same server. Can not transfer to external websites.
  • Known issue: when bln is set to true.. click to open. The problem is, the _VIEWSTATE is also transferred to the new aspx page. This causes the ASP.NET machine authentication check (MAC) to assume that the ViewState of the new page has been tampered with. Solution is to set EnableViewStateMac to false in the new page.


  • Works similar to Server.Transfer, only difference is, in Server.Transfer the current execution is terminated and the control is transferred to new page. In Server.Execute, it is like a function call. The control moves to the new page, and returns back to the called page.
  • If bln == true, all the form variables are transferred, so EnableViewStateMac to false in the new page
  • Once the call is returned back, the response stream of the new page is added to the response stream of the called page. To have more control, the response of the new page can be fetched into a TextWriter and can be placed where ever required. Sample code given below:
    System.Text.StringWriter sw = new System.Text.StringWriter();
    lbl.Text = sw.ToString();


Post a Comment

<< Home