Marty Trenouth
Marty Trenouth

Reputation: 3752

Server.MapPath not returning expected path

I've been handed alegacy (Classic ASP), red headed step child who has been beaten, shot and otherwise maimed by a number of people before my time, application and for the life of me I can't figure out how it's actually working on production (I even got a copy from production just in case the files weren't up to date in source control).

I have code that does the following

tmpDefaultXSLFile="xsl/SomeValue"
...
objXsl.load(Server.MapPath(tmpDefaultXSLFile & ".xsl"))

However, Server.MapPath seems not to map the file to the expected location (i.e."\asp_file_directory\xsl\SomeValue.xsl" and the modification required is to the xsl file.

Is there ANY way that the system could be fooled into have Server.MapPath map somewhere else?

Upvotes: 3

Views: 915

Answers (2)

Dee
Dee

Reputation: 1420

server.mappath(Path) specifies the relative or virtual path to map to a physical directory.

If Path starts with either a forward (/) or backward slash (\), the MapPath method returns a path as if Path is 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.

Upvotes: 0

amit_g
amit_g

Reputation: 31240

Looks like virtual directory on IIS is causing this. Check the URL and compare it to the directory structure within IIS including the virtual.

Upvotes: 1

Related Questions