Execute

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.

Syntax

Server.Execute( Path )

 

Parameters
Path
A string specifying the location of the .asp file to execute. If an absolute path is specified for this parameter then it must be for an .asp file within the same application space.
Remarks

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 includes.

After IIS processes the .asp file specified in the input parameter to Server.Execute, the response is returned to the calling ASP script. 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 will generate an error.

The path parameter may be for either an absolute or a relative path. If the path is absolute, it must map to an ASP script in the same application as the calling .asp file.

If either the calling or called .asp file contains a transaction directive, the status of the transaction will apply to the .asp file which contains the directive. For example, if ASP1 below calls ASP2 and the transaction is aborted while ASP2 is being processed, ASP2's OnTransactionAbort (if present) will be called. After ASP2 completes processing, ASP1's OnTransactionAbort (if present) will be called.

ASP1:
<%@ Transaction=Required%>
<% 
  Server.Execute ("Page22.asp") 

  Sub OnTransactionAbort

  Sub OnTransactionCommit
%>

Asp2.asp:
<%@ 
  Transaction=Required

  Sub OnTransactionAbort

  Sub OnTransactionCommit
%>
Example

The following example demonstrates executing an .asp file that returns some text. The output from these two scripts is:

I am going to ASP2

Here I am

ASP1

<HTML><BODY><%  Response.Write("I am going to execute ASP2 <BR>")
  Server.Execute("/myasps/asp2.asp")
%>
</BODY>
</HTML>

ASP2

<HTML><BODY><% Response.Write("Here I am")%></BODY></HTML>
Applies to

Server Object

See Also

Transfer, OnTransactionAbort, OnTransactionCommit