Microsoft KB Archive/224363

= Using the Server.Execute Method =

Article ID: 224363

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q224363



SUMMARY
One of the new Active Server Page (ASP) features introduced with Internet Information Services (IIS) version 5.0 is an execute method for the ASP built-in server object. This new method allows an ASP page to execute a child ASP page and treat it as part of the parent page.



MORE INFORMATION
Unlike the Server Side Includes (SSI) #exec command in IIS, which is used to run an executable file, or the SSI #include command, which is also used in ASP, the Server.Execute method is used with ASP pages to execute another ASP page. This allows greater flexibility in ASP execution by allowing conditional execution.

For example, the #include command is processed before the page is executed, whereas the Server.Execute method can be used after the page processing is started, allowing the programmer to choose which page to execute depending on user input.

The following example ASP code illustrates the Server.Execute method and conditional execution.

Save the following ASP code as "Execute.asp" (without the quotation marks) to a Web folder with Script Access enabled: <%@LANGUAGE="VBSCRIPT"%> Server.Execute Example Server.Execute Example Default Page This page is executing at <%=Request.ServerVariables("URL")%> " method="GET"> Default Page Page One Page Two  <% If Request.QueryString("page")="" Then %> <% Else %> "> Browse <%=Request.QueryString("page")%> <% Server.Execute Request.QueryString("page") %> <% End If%>

Save the following page in the same Web folder as "Page1.asp":

<%@LANGUAGE="VBSCRIPT"%> Page 1 Page 1 This page is executing at <%=Request.ServerVariables("URL")%>

Save the following page in the same Web folder as "Page2.asp": <%@LANGUAGE="VBSCRIPT"%> Page 2 Page 2 This page is executing at <%=Request.ServerVariables("URL")%>

Notes:
 * When the parent page is browsed, it will execute the second two child pages and include their output in a table.
 * When a child page is chosen in the form and submitted, only that child page is executed.
 * In each of the above cases, all pages list their URL as the parent page's URL, because they are executing within the scope of the parent page.
 * When either of the child pages are browsed directly, they list their respective URL as expected.

For more information, please see the Microsoft Scripting Technologies Web site.

Additional query words: iis ssi asp

Keywords: kbcodesnippet kbinfo kbscript KB224363

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.