Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Server.Transfer Method

IIS 6.0

The Transfer method sends all of the information that has been assembled for processing by one .asp file to a second .asp file.

Transfer(
   Path
)

Path

The location of the .asp file to which control should be transferred.

This method has no return values.

The following example demonstrates transferring from one .asp file to another, as well as sending the session identifier to the client.

The output from these scripts is:

A session ID

I am going to ASP2

The same session ID


--- ASP1 --- 
<HTML><BODY> 
  <% Dim sessvar1  Response.Write Session.SessionID 
  Response.Write ("<BR>") 
  Response.Write("I am going to ASP2 <BR>") 
  Server.Transfer("/Myasps/ASP2.asp") 
  %> 


--- ASP2 --- 
<HTML> 
<BODY><% Response.Write Session.SessionID%> 
</BODY> 
</HTML> 

Applies To

When you use the Transfer method, the state information for all the built-in objects are included in the transfer. This means that any variables or objects that have been assigned a value in session or application scope are maintained. In addition, all of the current contents for the Request collections are available to the .asp file that is receiving the transfer.

The Transfer method returns the ASP 0173 error, "Invalid Path Character", if the Path parameter contains any of the following characters:

  • Asterisk (*)

  • Question mark (?)

  • Angle brackets (< or >)

  • Comma (,)

  • Colon or semi-colon (: or ;)

  • Single-quote or double-quote (' or ")

  • Right square bracket (])

  • Double slashes (// or \\)

If the path you specify in the input parameter is for an .asp file in another application, the .asp file executes as if it were in the application that contains the Server.Transfer command. In other words, all variables and objects that have been given application scope either by other .asp files in the application or by the application's Global.asa file are available to the called .asp file. However, the path parameter must not contain a query string, or ASP returns an error.

Server.Transfer acts as an efficient replacement for the Response.Redirect method. Response.Redirect specifies to the browser to request a different page. Because a redirect forces a new page request, the browser makes two requests to the Web server, so the Web server handles an extra request. IIS 5.0 introduced a new function, Server.Transfer, which transfers execution to a different ASP page on the server. This avoids the extra request, resulting in better overall system performance, as well as a better user experience.

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

Show:
© 2014 Microsoft