The Execute method calls an .asp file, and processes it as if it were part of the calling ASP script. The Execute method is similar to a procedure call in many programming languages.
Execute( Path )
A string specifying the location of the .asp file to execute. The Path parameter may be for either an absolute or a relative path. If Path is absolute, it must map to an ASP script in the same application as the calling .asp file. Path can be a string variable name that is set at run-time. The Path parameter must not contain a query string, or IIS returns an error.
This method has no return values.
In the following example, the browser language determines which .asp file is executed. (Languages with multibyte characters have not been included in this example because of code page incompatibilities.) The output from these scripts on a U.S. system is:
Company Name Welcome to my Website!
The output from these scripts on a German system is:
Company Name Willkommen zu meinem Website!
The output from these scripts on a Spanish system is:
Company Name Recepción a mi Website! --- Welcome.asp --- <HTML> <BODY> <H1>Company Name</H1> <% AcceptLang = Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") Lang = Left(AcceptLang, 2) Server.Execute(Lang & "Welcome.asp") %> </BODY> </HTML> --- EnWelcome.asp --- <% Response.Write "Welcome to my Website!" %> --- DeWelcome.asp <% Response.Write "Willkommen zu meinem Website!" %> --- EsWelcome.asp --- <% Response.Write "Recepción a mi Website!" %>
The Server.Execute method provides a way of dividing a complex application into individual modules. By employing the Server.Execute method, you can develop a library of .asp files that you can call as needed. This approach is an alternative to server-side include directives. The major difference is that you can dynamically call an .asp file by using Server.Execute.
The Server.Execute method returns the ASP 0173 error, "Invalid Path Character", if the Path parameter contains any of the following characters:
Question mark (?)
Angle brackets (< or >)
Colon or semi-colon (: or ;)
Single-quote or double-quote (' or ")
Right square bracket (])
Double slashes (// or \\)
After IIS processes the .asp file specified in the input parameter to Server.Execute, the response is returned to the calling ASP script.
The following collections and properties are available to the executed ASP page:
Application variables, even if they are set in the calling page.
Session properties, even if they are set in the calling page.
Server variables and properties, even if they are set in the calling page.
Request collections and properties, even if they are set in the calling page. This includes Form and QueryString data passed to the calling page.
Response collections and properties. The executed .asp file may modify HTTP headers. However, as with any .asp file, if the executed .asp file attempts to modify HTTP headers after it sends a response to the client, it generates an error.
If a file is included in the calling page by using #include, the executed .asp will not use it. For example, you may have a subroutine in a file that is included in your calling page, but the executed .asp will not recognize the subroutine name. You must include the file in each executed .asp that requires the subroutine.
If either the calling or called .asp file contains a transaction directive, the status of the transaction will apply to the .asp file that contains the directive. For example, if ASP1 below calls ASP2 and the transaction is aborted while ASP2 is being processed, the ASP2 OnTransactionAbort (if present) is called. After ASP2 completes processing, the ASP1 OnTransactionAbort (if present) is called. The following code demonstrates this.
ASP1: <%@ Transaction=Required %> <% Server.Execute ("ASP2.asp") Sub OnTransactionAbort Sub OnTransactionCommit %> ASP2.asp: <%@ Transaction=Required %> <% Sub OnTransactionAbort Sub OnTransactionCommit %>
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.