HOWTO: Dynamically Include Files in Active Server PagesID: Q192144
|
Since Active Server Pages (ASP) pages are compiled and executed before being sent to the client (as static HTML), trying to use a variable in place of a file name in a Server Side Include (<!-- #include PathType = FileName -->) fails. To include a file in your ASP page, you could include code similar to the following that reads in a file and displays it.
<% ' The name of the file to display was passed by a form using GET method
infil = Request.QueryString("file")
If infil <&>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set fil = fso.OpenTextFile(infil)
outstring = fil.ReadAll
' PRE tags preserve the format of the file
Response.write "<PRE>" & outstring & "</PRE><BR>"
End If
%>
For additional information, please see the following article in the
Microsoft Knowledge Base:
Q172024 INFO: Server Side Include Directives Not Processed by ASP
Additional query words:
Keywords : kbASP kbJScript kbScript kbVBScript kbVisID kbGrpASP
Version : WINDOWS:1.0,6.0; winnt:
Platform : WINDOWS winnt
Issue type : kbhowto
Last Reviewed: May 27, 1999