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!

Include not working on the asp

Status
Not open for further replies.

lcky

Programmer
Sep 29, 2005
30
0
0
GB
Hi

I have this include on my asp page.
<!-- #include virtual="../asp/topHeader.asp" -->
It doesn't work.

This is my folder structure; myWebsite/asp/topHeader.asp

I have similar structure at my second website and it work.
Only different is mySite/asp/topHeader.asp

I am confused here. Please could you help me.

Also Is there any way I can add base root of my website on the asp page. And then I refrence everything to that reference.


Many thank



 
Code:
<!-- #include virtual="/asp/topHeader.asp" -->
 
lcky, if both sites are the same but the include you show is not working on one and is on the other then the former site may have disabled parent paths.
Using ../asp/topHeader.asp is telling the server to back up to the parent folder then go into the asp folder and grab the named file. If parent paths are disabled the .. will not work to reference the parent folder so instead you will have to use an absolute path.
For instance, if your asp folder is off the root of the web server folders then /asp/topHeader.asp will work.
If however the asp folder was in a subfolder called scripts then you would need to use /scripts/asp/topHeader.asp. You have to give it a full path to the file starting from the web servers root folder (not the root of the hard drive).

You can also use the relative path from where you currently are if the file you want is in the same folder or a sub folder.
Example:
Current path rootfolder/scripts look for file in scripts/asp
Looking for file in same folder.
<!-- #include virtual="topHeader.asp" -->
Looking for file in asp sub folder.
<!-- #include virtual="asp/topHeader.asp" -->
Looking for file in scripts folder.
<!-- #include virtual="/scripts/topHeader.asp" -->
Adn if your are in a different folder like rootfolder/other and looking for file in scripts/asp
<!-- #include virtual="/scripts/asp/topHeader.asp" -->

Using the backslash at the beginning tells the script to start looking at the root then traverse whatever sub folders are named.

Parent Paths can be disabled for the whole server or for just an application and that might be why you see a difference from one site to the other.


Stamp out, eliminate and abolish redundancy!
 
Icky,

To my knowledge, using "virtual" assumes you will be giving a file structure based from the root directory of your website. If in myWebsite/asp/topHeader.asp the "myWebsite" folder is not the root folder for the website, it won't work. If mySite in the other is, that could be why. If instead of going from the root of the directory you want to include a file based on the relative relation to the file (i.e. going back one folder using ../), then use "file" instead of "virtual".

So, if you want to go relative to current file, type:
Code:
<!-- #include file="../asp/topHeader.asp" -->

or else use from the base folder like this:
Code:
<!-- #include virtual="/myWebsite/asp/topHeader.asp" -->


<!-- #include virtual="../asp/topHeader.asp" -->


-Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top