Product Home Page | Developer Site | Version | |
The Server.Execute method provides a way to divide complex applications into individual modules. You can use Server.Execute to run ASP code on another page, returning to the original page when the code has finished executing.
By employing the Server.Execute method, a library of .asp files can be developed and then called as needed. This approach is similar to server-side includes, with the only major difference being that Server.Execute allows you to dynamically call an .asp file. Because Server.Execute is an ASP method rather than an HTML comment, it can be used to conditionally execute scripts and avoid including huge include files. Server-side includes are executed prior to any ASP code and thus can’t be executed conditionally.
Server.Execute does have some potential drawbacks, which are listed below. In many situations, though, using Server.Execute is a better choice than using server-side includes.
Potential drawbacks to Server.Execute:
Server.Execute cannot call a particular procedure on the included page. It starts running code at the top of the executed page and continues until the executed page ends, at which point it returns to the original page.
Page-scope variables are not shared between the original page and the executed page. This isn’t an issue with server-side includes because the include file code is incorporated into the original page before being executed.
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.