Posted by: savagerider | September 23, 2007

Navigating in ASP.NET pages

There are 3 ways for us to navigate in ASP.NET pages.

 1. Response.redirect(“yourWebPage.aspx”);

This is way of navigating to new page is not new to us. We could redirect the page from any webserver. There several limitations on this method:

a) Unable to pass VIEWSTATE / Session / Application session parameters to redirected page.

2. Server.Transfer(“yourWebPage.aspx”, isPreserveForm);

We could pass the parameters from originating page to destinated page if isPreserveForm is set to true. The viewstate field of the originating page will be added to the destinated page, this causes the response stream is different with only destinated page alone. In this case, we need to turn off the consistency checking (ViewStateMac) on viewstate.We will have limitation on using this method to redirect page from the same web server, this will limit the scalability of the application.

3. Server.Execute(“yourWebPage.aspx”,TextWriter);

Page B will return back to Page A (originating page) after execution. This inherited the limitation from Server.Transfer, where the page must be from the same web server. The result of Page B is stored in TextWriter if it is set in 2nd parameter.

StringWriter sw = new StringWriter();Server.Execute(“WebForm2.aspx”,sw);

TextBox2.Text = sw.ToString();


Leave a response

Your response:

Categories