Howto get the current file path with SSI

Ask a Question related to ASP Components, Design and Development.

  1. #1

    Default Howto get the current file path with SSI

    Hi All,

    In my ASP file, located at the "/test" directory of the website, I include
    another ASP file as below.

    <!--#include file="../templates/_header.asp"-->

    Inside the _header.asp file, how can I get the current file (_header.asp)
    directory? I need to get the web relative/absolute directory of _header.asp,
    but instead even if I can get the physical directory location of that file
    should be fine.

    I tried Request.ServerVariables("") with almost all the variables, but none
    gave me what I wanted. This is necessory, becase the location of _header.asp
    and the file which includes that can vary.

    Please give me a help/clue as soon as possible.

    Thanks in advance!
    Eranga


    Eranga Udesh Guest

  2. Similar Questions and Discussions

    1. Library path relative to current .rb file
      One of the most irritating (missing) features of Ruby is inability to 'require' files in the same directory or subdirectories as the executing...
    2. How to get the full path of the current open PDF file?
      How to get the full path of the current open PDF file from PDDOC or AVDOC?? Thanks!!
    3. #25444 [Bgs->Opn]: php4isapi.dll path to win.ini doesn't load from current path.
      ID: 25444 User updated by: ict at primus dot ca Reported By: ict at primus dot ca -Status: Bogus +Status: ...
    4. #25444 [Opn->Bgs]: php4isapi.dll path to win.ini doesn't load from current path.
      ID: 25444 Updated by: sniper@php.net Reported By: ict at primus dot ca -Status: Open +Status: Bogus...
    5. #25444 [NEW]: php4isapi.dll path to win.ini doesn't load from current path.
      From: ict at primus dot ca Operating system: W2K PHP version: 4.3.3 PHP Bug Type: *Configuration Issues Bug description: ...
  3. #2

    Default Re: Howto get the current file path with SSI


    Hi

    Try this

    Server.MapPath(Request.ServerVariables("SCRIPT_NAM E"))

    or this

    Request.ServerVariables("PATH_TRANSLATED")

    Let me know if this helped u...

    Rgds
    Surjit


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Surjit Madiwalar Guest

  4. #3

    Default Re: Howto get the current file path with SSI

    You can't, since the ASP code inside the include file thinks it is being
    executed from the file calling it. One thing you might consider is
    declaring a variable in the parent file, and referencing it in the #include
    file.

    <%
    scr = request.servervariables("SCRIPT_NAME")
    includedPath = left(scr,instrRev(scr,"/")-1) & "/templates/_header.asp"
    %>
    <!--#include file="../templates/_header.asp"-->

    (Then reference the includedPath variable within the include file.)

    Next time, please take a look at your cross-post list. This has nothing to
    do with databases or components, and certainly has nothing to do with
    ASP.NET. Followups set to asp.general ONLY.





    "Eranga Udesh" <eranga@omnibis.com> wrote in message
    news:%23e6vsqrGEHA.1720@tk2msftngp13.phx.gbl...
    > Hi All,
    >
    > In my ASP file, located at the "/test" directory of the website, I include
    > another ASP file as below.
    >
    > <!--#include file="../templates/_header.asp"-->
    >
    > Inside the _header.asp file, how can I get the current file (_header.asp)
    > directory? I need to get the web relative/absolute directory of
    _header.asp,
    > but instead even if I can get the physical directory location of that file
    > should be fine.
    >
    > I tried Request.ServerVariables("") with almost all the variables, but
    none
    > gave me what I wanted. This is necessory, becase the location of
    _header.asp
    > and the file which includes that can vary.
    >
    > Please give me a help/clue as soon as possible.
    >
    > Thanks in advance!
    > Eranga
    >
    >

    Aaron Bertrand [MVP] Guest

  5. #4

    Default Re: Howto get the current file path with SSI

    You can't, since the ASP code inside the include file thinks it is being
    executed from the file calling it. One thing you might consider is
    declaring a variable in the parent file, and referencing it in the #include
    file.

    <%
    scr = request.servervariables("SCRIPT_NAME")
    includedPath = left(scr,instrRev(scr,"/")-1) & "/templates/_header.asp"
    %>
    <!--#include file="../templates/_header.asp"-->

    (Then reference the includedPath variable within the include file.)

    Next time, please take a look at your cross-post list. This has nothing to
    do with databases or components, and certainly has nothing to do with
    ASP.NET. Followups set to asp.general ONLY.





    "Eranga Udesh" <eranga@omnibis.com> wrote in message
    news:%23e6vsqrGEHA.1720@tk2msftngp13.phx.gbl...
    > Hi All,
    >
    > In my ASP file, located at the "/test" directory of the website, I include
    > another ASP file as below.
    >
    > <!--#include file="../templates/_header.asp"-->
    >
    > Inside the _header.asp file, how can I get the current file (_header.asp)
    > directory? I need to get the web relative/absolute directory of
    _header.asp,
    > but instead even if I can get the physical directory location of that file
    > should be fine.
    >
    > I tried Request.ServerVariables("") with almost all the variables, but
    none
    > gave me what I wanted. This is necessory, becase the location of
    _header.asp
    > and the file which includes that can vary.
    >
    > Please give me a help/clue as soon as possible.
    >
    > Thanks in advance!
    > Eranga
    >
    >

    Aaron Bertrand [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139