HttpServerUtility.Transfer Method (String, Boolean)
[Visual Basic] Overloads Public Sub Transfer( _ ByVal path As String, _ ByVal preserveForm As Boolean _ ) [C#] public void Transfer( string path, bool preserveForm ); [C++] public: void Transfer( String* path, bool preserveForm ); [JScript] public function Transfer( path : String, preserveForm : Boolean );
- The URL path of the new page on the server to execute.
- If true, the QueryString and Form collections are preserved. If false, they are cleared. The default is false.
|HttpException||The resource cannot be found.|
The page transferred to should be another .aspx page. For instance, a transfer to an .asp or .asmx page is not valid.
If you set preserveForm to true and if the enableViewStateMac attribute of the <pages> Element configuration element is true, ASP.NET will raise an exception when Transfer is executed because the view state from the page that calls Transfer is not valid on the destination page. One of the preserved form fields on the calling page is the hidden __VIEWSTATE form field, which holds the view state for the page. When enableViewStateMac is true, ASP.NET runs a message authentication check (MAC) on the view state of the destination page when the page is posted back from the client and the check will fail. For security purposes, you should keep the enableViewStateMac attribute set to true but there are other methods available to transfer Forms data. For more information, including recommended solutions, see article Q316920, "View State is Invalid Error Message When You Use Server.Transfer" in the Microsoft Knowledge Base at http://support.microsoft.com.
The following example executes a new page in the same directory as the current page.
[Visual Basic] Server.Transfer("Logon.aspx") [C#] Server.Transfer("Logon.aspx"); [C++] Server->Transfer(S"Logon.aspx"); [JScript] Server.Transfer("Logon.aspx")
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family