Print Page | Close Window

Include Virtual/File

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14147
Printed Date: 30 March 2026 at 11:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Include Virtual/File
Posted By: vtech
Subject: Include Virtual/File
Date Posted: 07 March 2005 at 7:16pm

Is there any way to include a file from a different folder on your web server?

I have files from my other domains in a different directory then my site i want to include them all and instead of having them twice i would prefer to be able to include the file using the exact path or something like that if possible.
 
If there is a way of doing this or an alternative that will work like this can someone please tell me ASAP.
 
Thanks in advance,
VTech



Replies:
Posted By: bootcom
Date Posted: 08 March 2005 at 2:59am

If you want to include a file from a different folder on your server simply do an include virtual. This maps from the root directory of your server so if you wanted to include default.asp from a folder called test simply do the following:

<!--include virtual="test/default.asp" -->
 
Is this what your looking for or did I miss the point ??


Posted By: vtech
Date Posted: 08 March 2005 at 6:34am
The problem i am having with that is its 2 different root folders. I am trying to keep it like this so my client cannot see/mess up the asp coding for their sites.    
 
 
If that does not work, is there an asp function that you can include pages from different sites?
 
Like say one page is on http://mysite.com/page.htm - http://mysite.com/page.htm and my site is http://othersite.com/ - http://othersite.com/ is there a way to make the page.htm show? Both sites are hosted on the same server just different root directories.


Posted By: michael
Date Posted: 08 March 2005 at 10:14am
If you have something like
webfolder/site1.com/page.asp
and
webfolder/site2.com/otherpage.asp
where a domain maps to each .com folder... say you want to include otherpage.asp in page.asp you could do 2 things:
<!--#include virtual="../site2.com/otherpage.asp"-->
or use File pretty much the same way, though it is relative to the calling file not the root.


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: bootcom
Date Posted: 08 March 2005 at 11:52am
Originally posted by michael michael wrote:

If you have something like
webfolder/site1.com/page.asp
and
webfolder/site2.com/otherpage.asp
where a domain maps to each .com folder... say you want to include otherpage.asp in page.asp you could do 2 things:
<!--#include virtual="../site2.com/otherpage.asp"-->
or use File pretty much the same way, though it is relative to the calling file not the root.
 
Dude, theres not too different root folders the root folder is the webfolder. If you map the virtual as:
 
<!--#include virtual="site2.com/otherpage.asp"-->
 
You should be fine.
 
Chris


Posted By: dj air
Date Posted: 08 March 2005 at 1:04pm
yes there is 2 root folders.

he wants to link a file from one site to another.... therefore 2 websites and therefore 2 root folders, 1 per a domain


Posted By: michael
Date Posted: 08 March 2005 at 2:11pm
Yeah Dude Tongue

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: vtech
Date Posted: 08 March 2005 at 2:45pm

Yes, I want what DJ said. Does anyone know if it is possible?



Posted By: dj air
Date Posted: 08 March 2005 at 3:06pm
i believe michael's post above tells you how to use the system you require


Originally posted by michael michael wrote:

If you have something like
webfolder/site1.com/page.asp
and
webfolder/site2.com/otherpage.asp
where a domain maps to each .com folder... say you want to include otherpage.asp in page.asp you could do 2 things:
<!--#include virtual="../site2.com/otherpage.asp"-->
or use File pretty much the same way, though it is relative to the calling file not the root.


Posted By: vtech
Date Posted: 08 March 2005 at 5:55pm
So do if the other folder is called Todd for example it would be

../todd/file.ext ?


Posted By: dj air
Date Posted: 08 March 2005 at 6:08pm
yes , i think thats right.

you can only test itLOL.

if michael is correct (bet he is)... it should be fine.


Posted By: michael
Date Posted: 08 March 2005 at 9:04pm
It's all theory man. basically with virtual you start at the root of your web so you do a .. to go up a level then you do /yourdirectory to go into the other site... it may looks something like ../../folder/file.ext if it's further up.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: vtech
Date Posted: 09 March 2005 at 6:44am
I tried and i am getting 

Active Server Pages error 'ASP 0126'

Include file not found

/test.asp, line 1

The include file '../SkyCrest0root/stats.htm' was not found.

The code i used was
<!--#include virtual="../SkyCrest0root/stats.htm"-->
and the page is there also.
 
Is there another way of doing this like by using the FSO to include it or something?


Posted By: xeerex
Date Posted: 09 March 2005 at 9:50am
You could use FSO to copy the file from one web root to the other each time a page is called. I'm not sure how much overhead this would add but it shouldn't be much. Then you would only have to worry about updating content in one website as the 2nd would use FSO to copy the correct file in. The only other consideration would be if you were copying an ASP page in that had includes or code that was dependent on other files.

Although I'm not positive, I think the include statements can only be used within a defined website. Using "include file", you can look above root in a defined site, but "include virtual" will only look below the root of the site.


-------------
http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production


Posted By: vtech
Date Posted: 09 March 2005 at 1:53pm
Okay, maybe if i explain a little more on what i am trying to do someone can tell me a workaround then.
 
For a website i am hosting i have 2 root folders, one has all the asp code and the site pretty much in it the other i want to use so that when the people logged in create pages for the site it stores all the pages on the other root folder.
 
SO in other words i dont want to mix the site with the content so i am putting it on a different directory.
 
 
All help is appreciated
Vtech


Posted By: xeerex
Date Posted: 09 March 2005 at 7:56pm
Sounds to me like the easiest way is to (1) use FSO to create .txt or .html files for the content or (2) Use a database to power the content, whether Access, SQL Server, or mySQL. If I had to chose I'd take (2).Smile

-------------
http://webspacegeeks.com - Need Hosting, Domains, Dedicated Servers?
http://www.smartergeek.com - web design | pc support | training | podcasts | video production


Posted By: vtech
Date Posted: 09 March 2005 at 11:51pm
IF anyone is interested to see how i solved this, here is the code that i used (sorry i couldnt find who coded this to give proper credit or any comments on it but it is pretty understandable)
 
 

<%
Function getFileContents(strIncludeFile)
  Dim objFSO
  Dim objText
  Dim strPage

  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

  Set objText = objFSO.OpenTextFile("D:\Inetpub\wwwroot\myrootfolder/" & strIncludeFile)

  getFileContents = objText.ReadAll

  objText.Close
  Set objText = Nothing
  Set objFSO = Nothing
End Function
%>

<%
Dim strMain

strMain = getFileContents("34efa.htm")

Response.Write strMain
%>

I specified my root folder at the top with the function so all i need to do is include then page other than that everything was pretty much how i found it.
 
Thanks for all the help that directed me towards this solution
VtechClap



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net