Howto get the current file path with SSI

Discussion in 'ASP General' started by Eranga Udesh, Apr 5, 2004.

  1. Eranga Udesh

    Eranga Udesh Guest

    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, Apr 5, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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], Apr 6, 2004
    #2
    1. Advertising

  3. Eranga Udesh

    Eranga Udesh Guest

    Hi Aaron,

    Thanks for the advice. Also I will make sure to check my cross-post list
    next time.

    Rgds,


    "Aaron Bertrand [MVP]" <> wrote in message
    news:%...
    > 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" <> wrote in message
    > news:%...
    > > 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, Apr 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eranga Udesh

    Howto get the current file path with SSI

    Eranga Udesh, Apr 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,099
    Aaron Bertrand [MVP]
    Apr 6, 2004
  2. farmer
    Replies:
    10
    Views:
    33,326
    farmer
    Oct 25, 2005
  3. Matt
    Replies:
    1
    Views:
    27,419
    Sudsy
    Jun 6, 2004
  4. Poten Tate

    Path for SSI in htm file

    Poten Tate, Apr 1, 2007, in forum: HTML
    Replies:
    18
    Views:
    681
    Joe (GKF)
    Apr 6, 2007
  5. Arnau Sanchez
    Replies:
    1
    Views:
    452
    rasmus
    Aug 23, 2007
Loading...

Share This Page