server.mappath problem.

Discussion in 'ASP General' started by Cozmo, Nov 30, 2005.

  1. Cozmo

    Cozmo Guest

    We have an .asp application , located in:

    e:\myapp

    In there we have directories like:

    e:\myapp\db
    e:\myapp\images
    e:\myapp\utils
    e:\myapp\working

    In global.asa we have a server.mappath("db") & "mydb.mdb" to get the db
    location

    This works MOST of the time, but sometimes the browser shows an error like:

    Cant find file e:\myapp\utils\mydb.mdg

    This is CLEARLY the wrong file path. Restarting iis or the website or
    reinitiallising the application will correct this and it generally works for
    a long time and then will do it again, quite randomly. (long time meaning
    sometimes months !)

    It seems to be a bug of some kind - is anyone aware of this I cannot find
    mention of it anywhere.
     
    Cozmo, Nov 30, 2005
    #1
    1. Advertising

  2. Cozmo

    McKirahan Guest

    "Cozmo" <> wrote in message
    news:...
    > We have an .asp application , located in:
    >
    > e:\myapp
    >
    > In there we have directories like:
    >
    > e:\myapp\db
    > e:\myapp\images
    > e:\myapp\utils
    > e:\myapp\working
    >
    > In global.asa we have a server.mappath("db") & "mydb.mdb" to get the db
    > location
    >
    > This works MOST of the time, but sometimes the browser shows an error

    like:
    >
    > Cant find file e:\myapp\utils\mydb.mdg
    >
    > This is CLEARLY the wrong file path. Restarting iis or the website or
    > reinitiallising the application will correct this and it generally works

    for
    > a long time and then will do it again, quite randomly. (long time meaning
    > sometimes months !)
    >
    > It seems to be a bug of some kind - is anyone aware of this I cannot find
    > mention of it anywhere.
    >


    You don't understand how to use Server.MapPath().

    server.mappath("db") will not do what you think it does.

    server.mappath("/db/mydb.mdb") may be what you need.
     
    McKirahan, Nov 30, 2005
    #2
    1. Advertising

  3. Cozmo

    Cozmo Guest

    Actually, I DO understand how it works (aside from the couple of typos in my
    post), and it works just fine - about 99.9% of the time.

    FYI , as you may not realize the difference, this is the functions method
    from M/S:

    If Path starts with either a forward (/) or backward slash (\), the MapPath
    method returns a path as if Path were a full, virtual path. If Path doesn't
    start with a slash, the MapPath method returns a path relative to the
    directory of the .asp file being processed.

    -- end clip --

    I am using a 'relative' path which is necessary as I dont know where my
    customers may install the application in relation to the root path or the
    root of the website or virtual web - the example you gave is a 'fixed' path
    from the root, where the one i showed allows the virtual path to be on the
    2nd level of a tree, or the 12th level of the tree ! I cannot use the fixed
    path, as I dont have control over where that may be - we may be at the root
    or at some subdirectory of the root, perhaps several layers deep !!


    "McKirahan" <> wrote in message
    news:...
    > "Cozmo" <> wrote in message
    > news:...
    >> We have an .asp application , located in:
    >>
    >> e:\myapp
    >>
    >> In there we have directories like:
    >>
    >> e:\myapp\db
    >> e:\myapp\images
    >> e:\myapp\utils
    >> e:\myapp\working
    >>
    >> In global.asa we have a server.mappath("db") & "mydb.mdb" to get the db
    >> location
    >>
    >> This works MOST of the time, but sometimes the browser shows an error

    > like:
    >>
    >> Cant find file e:\myapp\utils\mydb.mdg
    >>
    >> This is CLEARLY the wrong file path. Restarting iis or the website or
    >> reinitiallising the application will correct this and it generally works

    > for
    >> a long time and then will do it again, quite randomly. (long time meaning
    >> sometimes months !)
    >>
    >> It seems to be a bug of some kind - is anyone aware of this I cannot find
    >> mention of it anywhere.
    >>

    >
    > You don't understand how to use Server.MapPath().
    >
    > server.mappath("db") will not do what you think it does.
    >
    > server.mappath("/db/mydb.mdb") may be what you need.
    >
    >
     
    Cozmo, Dec 1, 2005
    #3
  4. Cozmo

    McKirahan Guest

    "Cozmo" <> wrote in message
    news:...
    > Actually, I DO understand how it works (aside from the couple of typos in

    my
    > post), and it works just fine - about 99.9% of the time.
    >
    > FYI , as you may not realize the difference, this is the functions method
    > from M/S:
    >
    > If Path starts with either a forward (/) or backward slash (\), the

    MapPath
    > method returns a path as if Path were a full, virtual path. If Path

    doesn't
    > start with a slash, the MapPath method returns a path relative to the
    > directory of the .asp file being processed.
    >
    > -- end clip --
    >
    > I am using a 'relative' path which is necessary as I dont know where my
    > customers may install the application in relation to the root path or the
    > root of the website or virtual web - the example you gave is a 'fixed'

    path
    > from the root, where the one i showed allows the virtual path to be on the
    > 2nd level of a tree, or the 12th level of the tree ! I cannot use the

    fixed
    > path, as I dont have control over where that may be - we may be at the

    root
    > or at some subdirectory of the root, perhaps several layers deep !!


    [snip]

    Try changing:
    server.mappath("db") & "mydb.mdb"
    to
    server.mappath("db/mydb.mdb")
     
    McKirahan, Dec 1, 2005
    #4
    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. Jon
    Replies:
    5
    Views:
    11,368
    Scott M.
    Jan 17, 2010
  2. Peter Row
    Replies:
    0
    Views:
    490
    Peter Row
    Mar 1, 2004
  3. =?Utf-8?B?dHBhcmtzNjk=?=

    server.mappath vs. request.mappath

    =?Utf-8?B?dHBhcmtzNjk=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,228
    Juan T. Llibre
    Mar 11, 2007
  4. Replies:
    4
    Views:
    1,009
    Juan T. Llibre
    Oct 7, 2007
  5. AAaron123
    Replies:
    11
    Views:
    1,221
    AAaron123
    Sep 9, 2009
Loading...

Share This Page