The ASP.NET version of the Server.Transfer method accepts a second argument which, if true, causes the query string and all the form’s fields to be transferred and made available to the destination page. However, when the destination page executes, the following error is likely to be generated:
The View State is invalid for this page and might be corrupted
The reason for this error is that the EnableViewStateMac attribute of the You avoid this problem by not passing True as the second argument of the Server.Transfer method. However, you must devise alternative ways to make the query string and controls’ values of the source page available to the destination page, if these values must be processed by the destination page. There are two ways to achive this. The easiest way is to make all controls on the source page public, as in: A safer way is to wrap these control’s values in properties: In both cases you can then access the actual value from the destination page as follows:Public Class WebForm1 Public WithEvents txtUserName As System.Web.UI.WebControls.TextBox ' ...End Class
Public Class WebForm1 Private WithEvents txtUserName As System.Web.UI.WebControls.TextBox ' ... ReadOnly Property UserName() As String Get Return Me.txtUserName.Text End Get End PropertyEnd Class
' inside the destination pageDim sourcePage As WebPage1 = DirectCast(Context.Handler, WebForm1)Dim userName As String = sourcePage.UserName