0

Lets suppose I have the following file structure, the top 4 of which are virtual dirs:

1/2/3/4/5/6/7/8

Is it possible, from a file in directory 8, to include a file in directory 4, using something like the following?

<!-- #include virtual="/4/5/6/a.asp" -->

Note that I don't have 8 levels of directories - I actually only have 3 in the format /ab/abCore/includes.asp, /ab/ab123/default.asp, /ab/ab123/ajax/ab.asp, /ab/ab123/actions/create.asp (may have more levels shortly) and would like to use the same includes in both default.asp and create.asp. The only way I can find is to use 'file' with '../' one or more times. ab is a virtual directory but abCore and ab123 are not. I need to reference virtual dir 'ab' from any files within any directories within this directory. I am just using 8 in my example merely to explain my situation better. Note that I have full control over IIS, defining which directories are virtual and so on.

If this is not very clear then please say (rather than downvoting) and I will try to rephrase.

ClarkeyBoy
  • 4,934
  • 12
  • 49
  • 64
  • not sure i understand but you can use ../ as long as you check "Allow parent path" in your IIS setting this will allow you to get to parent folder using virtual includes.. – Mortalus Sep 08 '12 at 18:05
  • Hi Mortalus, yes I know about using ../, and that is what I am currently using, but what I'd like to do is use the exact same includes for all pages, not have to add an extra ../ for each subdirectory. I *think* have found a solution.. I just created a virtual dir called 'ab' in the root folder so I can use /ab/abCore. Basically the original ab directory is not the top folder - it is more like a/b/c/ab. c has its own web.config and global.asa which I thought wouldn't affect 'ab' if it was in the web root, however it seems to work fine :) – ClarkeyBoy Sep 08 '12 at 19:06
  • I think URL-rewriting would make your life much easier. – Shadow The GPT Wizard Sep 09 '12 at 07:25
  • thanks Shadow Wizard, but for now just having one virtual dir called ab in the webroot (which I have full control over anyway) serves my purpose. If I find it is a bit tedious in a few weeks then I will consider looking into URL rewriting. The aim is to have the app ready for phase 1 launch within 2 weeks and still as demoable as it is now in a week, hence I am not even considering URL rewriting at this stage as I have too much to do. – ClarkeyBoy Sep 09 '12 at 11:44

1 Answers1

0

Yes it can be done. Suppose there is a file test1.asp in f1 folder and you want to include it in a file which is in the path f1/f2/f3. Simply you need to write the code like

<!--#include file = "..\..\test1.asp"-->

So here is your answer. Your code should be like

<!--#include file = "..\..\..\..\a.asp"-->
polin
  • 2,745
  • 2
  • 15
  • 20