Due to the <!#includefile="filename.asp"--> macro restrictions, the file must exist and will be precompiled (regardless of whether the conditions were previously applied)
There are often such requirements. Different files are required to include according to different needs, such as different settings of each individual, so the requirements are to include files dynamically.
The code is as follows:
The code copy is as follows:
Functioninclude(filename)
Dimre, content,fso,f,aspStart,aspEnd
setfso=CreateObject("Scripting.FileSystemObject")
setf=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
setf=nothing
setfso=nothing
setre=newRegExp
re.pattern="^/s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
dowhileaspStart>aspEnd+1
Response.writeMid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%/>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write"))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.writeMid(content,aspEnd)
setre=nothing
EndFunction
Example of usage:
The code copy is as follows:
include("youinc.asp")