Dynamic Includes

ASP does not support dynamic includes (variable) by <!--#include--> tag. But if the included file is clear-text (or HTML), you can use FileSystemObject and next code to include the file :
<%
    FileName = Server.MapPath(Request.QueryString("include"))
    Response.Write CreateObject("Scripting.FileSystemObject").OpenTextFile _
    (FileName, 1, False, False).readall
%>
And then you can call the ASP : http://server/thefile.asp?include=myinclude.htm
Be sure that the client can read only allowed files (the code enables read all text files on the server !).
You can use Select Case :
<%
    FileName = Server.MapPath(Request.QueryString("include"))
    Select Case LCase(FileName)
       Case "file1.htm", "file2.htm" : FileName = FileName
       Case Else : FileName = "AccessDenied.htm"
    End Select
%>


asp .inc includes dynamic howto reference examples samples source code demos tips


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site