IIS 7 and Above
Need to access sibling directory from a classic asp include statement...
Last post Jan 31, 2018 09:42 AM by Yuk Ding
Jan 29, 2018 04:03 PM|SunnyOz|LINK
Basically, my question is... since I can't go up a level in the include statement anymore, can I use an
absolute path in a classic asp include statement? If so, what is the exact format to use?
Here is my situation:
I am migrating an old classic asp website from a Windows server running an old IIS to a Windows2008-2 server with IIS7.5 and running classic asp.
This new server does not have parent paths enabled (and they won't turn it on, and I can't get access to IIS control panel - as I am sharing the server with others).
So I am left with trying to find a way to re-code the includes that used to use a
relative path to get to a sibling directory.
Here is my setup:
I use their free shared ssl and both these files need to be accessed securely (the secure path is:
I have an an .asp file located at: /SMPSECR/my-inc.asp
I have a another .asp file located at: /PBB/my-test.asp
Inside of my-test.asp, I want to include my-inc.asp
On the old hosting server - I used to use this format:
but since IIS6 that doesn’t work anymore (as I mentioned earlier parent paths are automatically disabled and my hosting company won't enabled it for security reasons as I am on a shared server).
It appears that IIS7.5 (with parent path disabled) won't allow you to start the path with ../ or even just /
The system support people from the hosting company suggested I use absolute path instead of relative.. I also read somewhere that you
can use virtual instead of file, but even that didn’t work for me.
What I have tried so far:
Here are the 10 different include tests (trying to use virtual and/or absolute paths)- that I have tried from inside of my-test.asp and failed for each one:
Just to be thorough.. I also tried these 8 tests.. but as I expected, they also all failed:
Can anyone give me another include format that could work with my setup. Or at the very least tell me
if it is even possible to use absolute path with parents paths disabled? (As I mentioned earlier.. it appears that the server does not like anything with a / in front.. but I could be wrong!) Or maybe tell me
the exact words I need to say to the hosting company's system support people to get them to tell me the correct absolute path?
Note: I am aware I can do a work around.. in that I could move the include file ( my-inc.asp) to be a child of the my-test.asp file - so that I can use a relative path in the include statement.. but I would prefer not to do that if possible! (The include
statement using relative path downstream works, but I am porting over an old website, and this kind of include statement is used in over 200 files!)
Jan 30, 2018 04:44 AM|Yuk Ding|LINK
I just test it on myside and the virtual directory did works fine.
For example, your file acrchetecture just like this
Then you need to to create a virtual directory which is mapped to \parent, then the virtual directory will looks like this:
Then you could be able to load the myvirtual\b.inc via
Not sure why but the relative path with #include seems a bit different while ~\ is not working.
Jan 30, 2018 08:20 AM|SunnyOz|LINK
Thanks @Yuk Ding, for your reply.
But I am still confused on what to do.
Just to clarify.. my directory structure is this:
So, from within my-test.asp, I want to include my-inc.asp.
I tried looking at the instructions on how to create a virtual directory, and it looks like I have to have access to IIS Manager, right?
Well, as I am on a shared server, I don't have access to the IIS Manager. So I guess that is what I have to ask the Tech Support people to do for me? If so, can you tell me if what I have written below is the correct info I need to provide them?
Should I be telling them to create a virtual directory called (for example): "my-virtual", which needs to be
mapped to the root/SMPSECR directory? So that my include statement which will be in this file: root/PBB/my-test.asp will look like this:
And this will really be accessing this file: root/SMPSECR/my-inc.asp?
Can you just confirm the above?
Jan 31, 2018 09:42 AM|Yuk Ding|LINK
The structure could looks like this:
/my-virtual<mapped to smpscr>
Then you could use <!--#include virtual="my-virtual/my-inc.asp"-->. I just test it on my side.