Does Server.MapPath value ever change?

sonata

Perch
I'm having a problem with another hosting company where the value returned by the Server.MapPath variable occasionally changes "all by itself". The hosting company says they are not doing something, but I don't see how this could possibly happen without some sort of activity on their part.

Has anyone else experienced anything like this? Is this normal behavior? I've never had a problem with any other hosting company.
 
Why would the path change unless something in the system was changing, like driver letters?
 
Stephen said:
Why would the path change unless something in the system was changing, like driver letters?
I have no idea. All I know is that they swear up and down that they haven't changed anything.

FYI: I will be moving this and all of my sites to JodoHost to escape this lack of customer support from my old provider. Not a lot of sites, just need some time to get it done.
 
Nope, never had MapPath change on me. They may have done something once, but if it changes from time to time, I doubt it's even anything they are doing, as it would create a lot of work for them. Can you give an example of what changes? Is it the drive letter or part of the path?
 
It's part of the path. I have an Access database in a directory above the actual site--for example C:\home\user\db\access.mdf. From time to time the Server.MapPath changes to be: C:\home\user\domain.com\db\access.mdf. Whenever this happens, obviously the database can't be reached by the application and I get a note from the client that their site isn't working. So, I move the database to reflect the new path, then after a day or two it reverts back to its orginal path, the client again sends a message that their site isn't working, and I have to move the database back.

I've never seen this happen before, and I've been building sites using Access databases for 6 years. I know I can hard-code the path (the provider's suggestion), but I hate losing the flexibility of using the actual server variables. Makes the code more portable and all that.
 
Now that is VERY odd! Only way I know that could be happening if is someone was actually moving your folder, which is NOT good.

I'd first change passwords, to make sure someone doesn't know the FTP password and moving the DB into public so they can download it. Then I would check logs to see if anyone opened this DB from a browser, they ONLY reason I can see this happening is that someone is wanting to download the database to make a copy of it, to steal or otherwise view the data contained therein.

Edit: this idea does not make sense, if they had FTP they would not need to move to public folder, so maybe scratch that....
 
Since the path is changing in a logical kind of way (that is, it's not nonsensical in that it reflects info the server knows, i.e. the domain name) then there may be something happening on the server which causes it. Assuming you're sure it's not your code.

IMO your provider should at least take the issue on board and do some tests instead of saying "it's not me". If your provider has not at least asked you for details such as this, and how regular (or not) it occurs and tries some code himself to see if it reflects the change you're seeing - that sort of thing - then I'd give the provider away as they may not have the level of expertise you require for good support.

Harsh, but you also have a business to run and need problems resolved before you lose your clients' confidence.
 
BTW, could you not give something like an if else on the mappath, so if one fails, it knows to else to the other one?

That way the site would not go down, but it is still ODD why it moves from outside webroot, into webroot(which is not good for security)
 
One thing I just thought of - if your provider has mirrored (redundant) servers, even two of them paired, then they may not have it configured properly.

I had the experience once of an Access database which would be updated by my code, then half an hour later lose the records that were added! Turned out they didn't have a good mirroring process and an updated MDB was being overwritten with an older version of itself from the mirrored server. They turned off mirroring for that domain and everything was fine thereafter.

If the other server is occasionally picking up traffic for that site, it may have the domain home paths different from the other server - hence MapPath will say two different things at different times.
 
I had a hosting company do this to me. Things broke on the site as a result. You don't do something like move the sites to a new physical location on the drive and not tell everyone. Never had that kind of problem here though.
 
Back
Top