We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Need to access sibling directory from a classic asp include statement on Windows 2008-2 running IIS7.5 with parent paths disabledRSS

3 replies

Last post Jan 31, 2018 09:42 AM by Yuk Ding

  • Need to access sibling directory from a classic asp include statement on Windows 2008-2 running I...

    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: https://ssl5.ssllock.net/mysite.com/)

    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:

    <!--#include file="../smpsecr/my-inc.asp"-->

    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:

    <!--#include file="https://ssl5.ssllock.net/mysite.com/smpsecr/my-inc.asp"-->
    <!--#include file="https://ssl5.ssllock.net/mysite.com/smpsecr/my-inc.asp"-->
    <!--#include file="\\n5200-2\iis7_www\f\s\mysite.com\www\smpsecr\my-inc.asp"--> 
    <!--#include virtual="\\n5200-2\iis7_www\f\s\mysite.com\www\smpsecr\my-inc.asp"-->
    <!--#include file="//n5200-2/iis7_www/f/s/mysite.com/www/smpsecr/my-inc.asp"-->
    <!--#include virtual="//n5200-2/iis7_www/f/s/mysite.com/www/smpsecr/my-inc.asp"-->
    <!--#include file="/clientdata/iis7_www/f/s/mysite.com/www/smpsecr/my-inc.asp"--> 
    <!--#include virtual="/clientdata/iis7_www/f/s/mysite.com/www/smpsecr/my-inc.asp"-->
    <!--#include file="\clientdata\iis7_www\f\s\mysite.com\www\smpsecr\my-inc.asp"-->
    <!--#include virtual="\clientdata\iis7_www\f\s\mysite.com\www\smpsecr\my-inc.asp"-->

    Just to be thorough.. I also tried these 8 tests.. but as I expected, they also all failed:

    <!--#include file="/smpsecr/my-inc.asp"--> 
    <!--#include virtual="/smpsecr/my-inc.asp"--> 
    <!--#include file="\smpsecr\my-inc.asp"--> 
    <!--#include virtual="\smpsecr\my-inc.asp"--> 
    <!--#include file="smpsecr/my-inc.asp"--> 
    <!--#include virtual="smpsecr/my-inc.asp"--> 
    <!--#include file="smpsecr\my-inc.asp"--> 
    <!--#include virtual="smpsecr\my-inc.asp"--> 

    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!)

    Thanks!

  • Re: Need to access sibling directory from a classic asp include statement on Windows 2008-2 runni...

    Jan 30, 2018 04:44 AM|Yuk Ding|LINK

    Hi SunnyOz,

    I just test it on myside and the virtual directory did works fine. 

    For example, your file acrchetecture just like this

        root

               \parent

                           \b.inc

                           \subfolder

                                            \test.asp

    Then you need to to create a virtual directory which is mapped to \parent, then the virtual directory will looks like this:

       root

               \parent

                           \b.inc

                           \subfolder

                                            \test.asp

               \myvirtual

    Then you could be able to load the myvirtual\b.inc via

    <!--#include virtual="virtual/b.inc"-->

    Not sure why but the relative path with #include seems a bit different while ~\ is not working.

    https://docs.microsoft.com/en-us/iis/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/classic-asp-parent-paths-are-disabled-by-default

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Need to access sibling directory from a classic asp include statement on Windows 2008-2 runni...

    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:

    root

    /PBB

    /my-test.asp

    /SMPSECR

    /my-inc.asp

    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:

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

    And this will really be accessing this file: root/SMPSECR/my-inc.asp?

    Can you just confirm the above?

    Thanks,

    SunnyOz

  • Re: Need to access sibling directory from a classic asp include statement on Windows 2008-2 runni...

    Jan 31, 2018 09:42 AM|Yuk Ding|LINK

    Hi SunnnyOz,

    Yes.

    The structure could looks like this:

    root

    /PBB

    /my-test.asp

    /SMPSECR

    /my-inc.asp

    /my-virtual<mapped to smpscr>

    /my-inc.asp

    Then you could use <!--#include virtual="my-virtual/my-inc.asp"-->. I just test it on my side.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.