Help with Server.MapPaths - aaaaaahhhh

Discussion in 'ASP General' started by Laphan, Sep 28, 2004.

  1. Laphan

    Laphan Guest

    Hi All

    Sorry to be irate, but the whole concept of Server.MapPaths really has me in
    a tiswas!!

    In order to confirm once and for all, could you please advise me on the
    following:

    1) There is no difference in putting '/' or '\' in the Server.MapPath param,
    eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
    they work the same - correct?

    2) I'm finally using my ISP's 'off-world' folder to store my Access DB (yes
    I know I should be using MSSQL) and I am trying to link my ASP files back to
    it using Server.MapPath in such a way that my ISP's file server structure
    and my local file server structure can read the same site without me having
    to have different connection strings for remote and local work.

    To explain my problem, please note the following:

    There are 2 folders to start with 1 called <htdocs> and 1 called <private>.
    The htdocs is the web share folder and the <private> one is the 'off-world'
    database store. A common practise I believe with IIS ISPs.

    In the <htdocs> I have the following folder structures:

    root level ... some ASP inc files ...

    <incs> folder ... some ASP inc files ... <sprocs> folder ... some ASP inc
    files ...

    <user-data> <pics> my uploaded pics

    Now this is where the weirdie comes. If my ASP inc file is in the
    <incs><sprocs> level my Server.MapPath for accessing the <pics> folder is
    "../user-data/pics/", however if I have an ASP inc file in the <incs> level
    then my MapPath is "../../user-data/pics"

    How is that?? Surely the <sprocs> folder would need more '../' than the
    <incs> folder which is one level up?

    If somebody could just give me a dummies run-down on how this works I would
    really appreciate it as I just don't get it.

    Thanks

    Laphan
    Laphan, Sep 28, 2004
    #1
    1. Advertising

  2. > 1) There is no difference in putting '/' or '\' in the Server.MapPath
    param,
    > eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
    > they work the same - correct?


    I wouldn't expect them to. Why would you use \ ?

    > Now this is where the weirdie comes. If my ASP inc file is in the
    > <incs><sprocs> level my Server.MapPath for accessing the <pics> folder is
    > "../user-data/pics/", however if I have an ASP inc file in the <incs>

    level
    > then my MapPath is "../../user-data/pics"


    Why the ../ ? Did you try /user-data/pics/ in both places?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
    Aaron [SQL Server MVP], Sep 28, 2004
    #2
    1. Advertising

  3. Laphan

    Laphan Guest

    Hi Aaron

    Thanks for the prompt reply. In response:

    1) I have no idea why I should use \ -- it makes about as much sense as
    using /, but my ISP sent me an example with \ in it. To me they seem to
    make no diff either way.

    2) I've tried the /user-data/pics and it kept saying path not found. I
    don't know why it irritating. How does this ../ thing work anyway? If I
    set it to this it works, but I just don't know why

    Your help (as always) is appreciated.

    Rgds Laphan


    Aaron [SQL Server MVP] <> wrote in message
    news:...
    > 1) There is no difference in putting '/' or '\' in the Server.MapPath

    param,
    > eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
    > they work the same - correct?


    I wouldn't expect them to. Why would you use \ ?

    > Now this is where the weirdie comes. If my ASP inc file is in the
    > <incs><sprocs> level my Server.MapPath for accessing the <pics> folder is
    > "../user-data/pics/", however if I have an ASP inc file in the <incs>

    level
    > then my MapPath is "../../user-data/pics"


    Why the ../ ? Did you try /user-data/pics/ in both places?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
    Laphan, Sep 28, 2004
    #3
  4. Laphan

    Laphan Guest

    Just another note on this.

    My local path is as follows:

    <asp> << this is my shared root folder, which I put all my test sites in,
    as separate folders. Probably not a good idea. The site in question
    therefore has the following path from the root:

    <asp><mysite> .. content folders and files in here

    My remote site is CURRENTLY as follows:

    <www.mydomain.com> << although all content is put into <htdocs> I don't
    have to specify this because the mydomain is mapped to this (correct?) and
    inside this root folder I have created a new folder called <test> and put
    all of the web content from above into this. A common practise by crap
    developers like me is that we put the site into a test folder before we
    transfer it to live.

    I believe the above is why I can't simply use "/user-data/pics" because my
    root level doesn't actually contain the necessary files and folders. Would
    I be right in saying that if I created a new web shared folder in my local
    IIS and put the files in the root of this new folder they would work fine
    and would I also be right in saying that if my remote content was on the
    root level rather than being in a test folder it would also work fine?

    Thanks

    Laphan


    Aaron [SQL Server MVP] <> wrote in message
    news:...
    > 1) There is no difference in putting '/' or '\' in the Server.MapPath

    param,
    > eg Server.MapPath("/fred/test.asp") or Server.MapPath("\fred\test.asp") -
    > they work the same - correct?


    I wouldn't expect them to. Why would you use \ ?

    > Now this is where the weirdie comes. If my ASP inc file is in the
    > <incs><sprocs> level my Server.MapPath for accessing the <pics> folder is
    > "../user-data/pics/", however if I have an ASP inc file in the <incs>

    level
    > then my MapPath is "../../user-data/pics"


    Why the ../ ? Did you try /user-data/pics/ in both places?

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
    Laphan, Sep 28, 2004
    #4
  5. I don't understand how to interpret all of your <notation>...

    How about show us the results of this, from both the <incs> folder and the
    <incs><sprocs> folder:

    on error resume next
    response.write "<P>" & server.mappath(".")
    response.write "<P>" & server.mappath("/")
    response.write "<P>" & server.mappath("../../user-data/")
    response.write "<P>" & server.mappath("../user-data/")
    response.write "<P>" & server.mappath("/user-data/")
    response.write "<P>" & server.mappath("../incs/")

    I don't think any of us are in the business of figuring out ISP's wacky
    storage conventions. I would be tempted to just put the database in a web
    folder somewhere. Name it with an ASP extension, so that if anyone has the
    motivation to actually find out where you keep your database file and what
    you call it, they will still have to gain local access to the machine in
    order to open it.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Laphan" <> wrote in message
    news:...
    > Hi Aaron
    >
    > Thanks for the prompt reply. In response:
    >
    > 1) I have no idea why I should use \ -- it makes about as much sense as
    > using /, but my ISP sent me an example with \ in it. To me they seem to
    > make no diff either way.
    >
    > 2) I've tried the /user-data/pics and it kept saying path not found. I
    > don't know why it irritating. How does this ../ thing work anyway? If I
    > set it to this it works, but I just don't know why
    >
    > Your help (as always) is appreciated.
    >
    > Rgds Laphan
    >
    >
    > Aaron [SQL Server MVP] <> wrote in message
    > news:...
    > > 1) There is no difference in putting '/' or '\' in the Server.MapPath

    > param,
    > > eg Server.MapPath("/fred/test.asp") or

    Server.MapPath("\fred\test.asp") -
    > > they work the same - correct?

    >
    > I wouldn't expect them to. Why would you use \ ?
    >
    > > Now this is where the weirdie comes. If my ASP inc file is in the
    > > <incs><sprocs> level my Server.MapPath for accessing the <pics> folder

    is
    > > "../user-data/pics/", however if I have an ASP inc file in the <incs>

    > level
    > > then my MapPath is "../../user-data/pics"

    >
    > Why the ../ ? Did you try /user-data/pics/ in both places?
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    Aaron [SQL Server MVP], Sep 28, 2004
    #5
    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. =?Utf-8?B?UGVyZG8=?=
    Replies:
    0
    Views:
    570
    =?Utf-8?B?UGVyZG8=?=
    Feb 6, 2004
  2. Peter Row
    Replies:
    0
    Views:
    457
    Peter Row
    Mar 1, 2004
  3. =?Utf-8?B?UmV6YQ==?=
    Replies:
    3
    Views:
    17,890
    Carlos Barini
    Jun 7, 2004
  4. Replies:
    0
    Views:
    428
  5. -
    Replies:
    2
    Views:
    386
    Alan Krueger
    Jul 29, 2005
Loading...

Share This Page