This documentation is archived and is not being maintained.

HttpServerUtility.Transfer Method (String, Boolean)

.NET Framework 1.1

Terminates execution of the current page and begins execution of a new page using the specified URL path to the page. Specifies whether to clear the QueryString and Form collections.

[Visual Basic]
Overloads Public Sub Transfer( _
   ByVal path As String, _
   ByVal preserveForm As Boolean _
public void Transfer(
 string path,
 bool preserveForm
public: void Transfer(
 String* path,
 bool preserveForm
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.


Exception Type Condition
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.

Transfer calls End which raises a ThreadAbortException exception upon completion.

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


The following example executes a new page in the same directory as the current page.

[Visual Basic] 





Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpServerUtility Class | HttpServerUtility Members | System.Web Namespace | HttpServerUtility.Transfer Overload List