Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with includes 3

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
1
0
US
<!--#include file=&quot;../Utils/colorConst.asp&quot; -->

This code works fine on PWS but when uploaded to server it says path can not begin with ..

any thoughts? -Pete
 
If your Utils-dir is located in your on the server, try using

<!--#include virtual=&quot;/Utils/colorConst.asp&quot; -->

instead...
 
Thanks I'll try that. What is the difference between file and virtual. Does file refer to physical address? Z:\section4\utils etc while virtual refers to an http? -Pete
 
Thanks so much it did the trick... but I do not understand why. -Pete
 
It's probably because changing to the directory before /utils would move beyond the root of the webserver. If using &quot;/utils/colorConst.asp&quot; worked and &quot;../utils/coorConst.asp&quot; did not, that is likely the problem.
 
No, I should have been more explicit in my &quot;it worked!&quot; phraseology ( is that a word?;-) )

structure
db
myapplication
utils
colorConst.asp
manager
ProjMngr.asp


I had the the line below in ProjMngr.asp:
<!--#include file=&quot;../Utils/colorConst.asp&quot; -->
but it returned an error saying &quot;..&quot; was not allowed in the include. I also tried:
<!--#include file=&quot;myapplication/Utils/colorConst.asp&quot; -->

But It did not work either, but
<!--#include virtual=&quot;myapplication/Utils/colorConst.asp&quot; -->

Did work, but I do not understand why or what the difference is between virtual and file includes. -Pete
 
I could be wrong but...I seem to remember reading that when using file, you're being explicit about the path while when using virtual, it looks everywhere on the machine (basically). Not sure why your first one didn't work...looks good based on the structure you show.
 
virtual starts from the of the web, then starts from there.

both examples assume that the root directory of your web is at C:\inetpub\
for ex:
<#!--include file=&quot;C:\inetpub\ -->
is the same as
<#!--include virtual=&quot;\myfile.htm&quot; -->

then to beat a point home:
<#!--include file=&quot;C:\inetpub\ -->
is the same as
<#!--include virtual=&quot;\incs\otherdir\myfile.htm&quot; -->

two reasons virtual is good:
1:)even if you move the folder around, as long as the web structure stays the same, none of your links will break.

2:)if you have someone else host your website, there's a very very good chance that your files will _not_ be located at C:\inetpub\ therefore, by using include file=&quot;hardcodedpath&quot; you would need to change it when you upload it. After a while, it becomes a really bad headache.

hth leo

------------
Leo Mendoza
lmendoza@students.depaul.edu
 
Stars for all who helped me understand this!

Have a happy day! -Pete
 
From IIS5 documentation

#include
The #include directive instructs the Web server to insert the contents of a file into an HTML page. The included file can contain any content that is valid within an HTML document. You must surround a directive with HTML comment delimiters.

This directive can be used in both ASP pages and HTML pages.

Syntax
<!-- #include PathType = FileName -->

Parameters
PathType

Specifies the type of the path to FileName. The path type can be one of the following:

Path Type Meaning
File The file name is a relative path from the directory containing the document with the #include directive. The included file can be in the same directory or in a subdirectory; it cannot be in a directory above the page with the #include directive.
Virtual The file name is a full virtual path from a virtual directory in your Web site.
-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top