问题
I have recently taken over a website written in Classic ASP which i had no previous experience with.
In the root of the site the default.asp has an include:
#include virtual="/inc/common.asp"
However when hosted on the web server or locally (IIS) it returns with an error which says the include file 'common.asp' could not be found. The inc folder exists in the same directory as the default.asp and the common.asp is in the inc folder.
Any help would be appreciated!
回答1:
You say that the inc folder is in the same folder as default.asp - however you don't say if this folder is root. #include virtual takes a path from root, so ensure that you have the full path in there.
There's a quick explanation of #include syntax here: http://www.w3schools.com/asp/asp_incfiles.asp
回答2:
You cannot start an include link in Classic ASP with a slash (/). So your include needs to be like:
#include file="inc/common.asp"
or #include file="../inc/common.asp" or include file="../../inc/common.asp"
Notice that I used "file" instead of "virtual"?
<!--#include file="inc/common.asp" -->
Also, unless your include is within the same folder, you will need to enable "parent paths" in IIS admin.
来源:https://stackoverflow.com/questions/16106820/virtual-include-not-working