I want to write a function that will include an external file, much like Server.Execute, but will pass along parameters. I'm aware that Server.Execute will pass along query parameters, but I'd like to pass data more generally. For instance:
' main.asp
MyInclude("external.inc", Array("mykey", "myval"))
' external.inc
Response.Write mykey
I doubt I can get quite that far without reading the external fine, twiddling it, and executing, but I'd like to get as close as reasonably possible. Also, if possible, I'd prefer avoiding using the query passing option for security reasons.
EDIT:
The criteria I'd like to fulfill, if possible, are:
- Dynamic inclusion (i.e. no SSI)
- Simple syntax to invoke (preferably a single function call)
- Simple include files (just HTML/ASP snippets)
- Passing as much data across as possible.
SSI fits 2, 3, and 4, and I'd use it in a heartbeat except that I don't want to hard-code explicit paths into my files. If I can use the machinery of VBScript, I can just specify the include's name and have the include function find it.
Reading a file and executing would satisfy 1, 2, and 4. 3 is violated because you couldn't put straight HTML in the include. I use this approach to import scripts because I don't need that ability, but with snippets, it's a must-have.
Server.Execute has 1, 2, and 3, but the only way (AFAICT) to pass the include data is to munge the query string. Preservation of the caller's execution context is impossible.
Writing the includes as classes would satisfy 1, 2, and 4. The include files would then be made vastly more complicated.