This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
One of the new Active Server Page (ASP) features introduced withInternet Information Services (IIS) version 5.0 is a transfer methodfor the ASP built-in Server object.
This new method is an alternative to using the Response.Redirectmethod to transfer to another page, and allows the transfer of theASP built-in and Error objects to a second page. In addition, thetransfer takes place on the server instead of forcing the browserto redirect to a new page.
When the Server.Transfer method is called, execution of the firstpage is terminated and execution of the second page begins. If thefirst page has started writing to the response buffer, the secondpage appends to the buffer instead of replacing it. If bufferingis on, then HTTP headers can be modified by the ASP file that itis transferred to. If buffering is off, the HTTP headers are notmodifiable by the ASP file that it is transferred to, unless nocontent has been sent by ASP yet. Additionally, multiple transferscan be called in succession, thereby chaining pages together.
The only data transferred to a second ASP page are the ASP built-in objects and the ASP Error object values from the first request.Any variables declared by the first ASP page are not available inthe second ASP page.
When you transfer to a page in another application, theApplication and Session objects will contain information from theoriginating application. Accordingly, the ASP page that it istransferred to is treated as part of the originatingapplication.
The following example pages illustrate how the Server.Transfermethod may be used. In this example, the starting page containstwo forms, one using the HTTP POST method and the other using theHTTP GET method. Both pages use the same second page that detectsthe HTTP method and transfers to a different third page for eachmethod used. Because the transfer method is being used, theRequest Object is still populated and the correct results from thefirst page are displayed on the respective third page.
Copy the following ASP code and save it as "page1.asp"(without the quotation marks):
Save the following code as "page2.asp" (without the quotationmarks):
<% @LANGUAGE="VBSCRIPT" %><html><body><h3>Step 2 - Transfer Page</h3><% Select Case UCase(Request.ServerVariables("REQUEST_METHOD")) Case "POST" Server.Transfer "page3a.asp" Case "GET" Server.Transfer "page3b.asp" Case Else Response.Write "An unknown HTTP verb was used." End Select%></body></html>
Save the following code as "page3a.asp" (without the quotationmarks):