Recommendation
============================
ASP dynamic include file
Example: Include ("youinc. asp ")
<%
Function include (filename)
Dim re, content, FSO, F, aspstart, aspend
Set FSO = Createobject ("scripting. FileSystemObject ")
Set F = FSO. opentextfile (server. mappath (filename ))
Content = f. readall
F. Close
Set F = nothing
Set FSO = nothing
Set Re = new Regexp
Re. pattern = "^ \ s * ="
Aspend = 1
Aspstart = instr (aspend, content, "<%") + 2
Do While aspstart> aspend + 1
Response. Write mid (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. Write mid (content, aspend)
Set Re = nothing
End Function
%>
============================
<% If xxx = "yyy" then %>
<! -- # Include file = "file1.asp" -->
<% Else %>
<! -- # Include file = "file2.asp" -->
<% End if %>
This will download unnecessary documents and affect the loading efficiency.
1)
If xxx = "yyy" then
Server. Execute ("file1.asp ")
Else
Server. Execute ("file2.asp ")
End if
2)
If xxx = "yyy" then
Server. Transfer ("file1.asp ")
Else
Server. Transfer ("file2.asp ")
End if
3)
If xxx = "yyy" then
Filespec = "file2.asp"
Else
Filespec = "file2.asp"
End if
Filespec = server. mappath (filespec)
Scr = "scripting. FileSystemObject"
Set FS = server. Createobject (SCR)
Set F = FS. opentextfile (filespec)
Content = f. readall
Set F = nothing
Set FS = nothing
Response. Write (content)
Note the following when using the above methods to implement the include function. We can set <! -- # Include file = "file. ASP "--> contains the webpage file. ASP is considered to contain file. an integral part of an ASP Web page is to save the content of the web page as another file. It can be said that they are originally a Web page, so the contained web page file. ASP inherits files. all parameter settings of ASP Web pages, including sessions, are not the same as those of other methods. The HTML syntax can be shared with the main web page, while ASP is independent, in general, special sessions cannot be transferred from the primary webpage to the contained webpage file. ASP.