Server.MapPath() works differently on 2 different machines, ideas?

Discussion in 'ASP .Net' started by Peter Row, Feb 23, 2004.

  1. Peter Row

    Peter Row Guest

    Hi,

    BACKGROUND:
    Win2K Server SP4, ASP.NET 1.1
    Win2K Pro SP4, ASP.NET 1.1
    I have a wrapper class around all the asp objects.

    Website physical directory structure (phoney names)
    Server:
    C:\MySite
    |_ _Settings
    |_ Root
    |_ Bin (contains the DLL)
    |_ XSL

    Development test machine
    C:\TestSite
    |_ _Settings
    |_ Root
    |_ Bin (contains the DLL)
    |_ XSL

    In both cases ParentPaths are enabled. In IIS the sites directory is set
    to C:\MySite\Root and
    C:\TestSite\Root respectively.

    I read in the settings file from the _Settings directory; working out the
    physical path with:

    Directory.GetParent(Asp.Server.MapPath("/")).FullName & "\"

    For some bizarre reason on the server this results in:
    C:\MySite\Root\_Settings

    ....but correctly on the development machine:
    C:\MySite\_Settings

    I have tried saying:
    Asp.Server.MapPath("~")
    .... instead, again, this works on the development machine but not on the
    server.

    The only difference as far as I can see is that the server site has it's own
    URL
    where as the development machine has a virtual root.

    This project is a port from a VB6/ASP app which worked fine with the same
    code
    as above.

    I think for some weird reason when running on the server it is somehow
    getting the
    "Bin" directory hence why the above is returned on the server. But I have
    tested
    it on my development machine against the compiled DLL and it still works
    even then.

    Any ideas as to what is going on would be most appreciated.

    Regards,
    Peter Row
     
    Peter Row, Feb 23, 2004
    #1
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.