![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: ASP and XML/XSL error [Thread Next] Re: ASP and XML/XSL errorTo: NULL Date: 1/3/2005 11:34:00 PM
> If I have two files, same name, different folder, which one will be found
> first using Server.MapPath? Does it look alphabetically or does it look
> at
> an unsorted list as to when the folders were created?
>
Only one will ever be found; the one that is in the folder mapped to the
virtual name. Server.MapPath only converts a virtual path to a physical
path. It gets that information from the IIS mapping for the site. So when
you said
loadXMLFile "freight100_0a.xml", "freight.xsl"
the parser was looking who knows where for the file. Actually, it's
probably looking relative to where the ASP dll is. Who knows.
But Server.MapPath("freight100_0a.xml") returns the actual filesystem path
of the file specified in the string. In this case it's assuming the file is
in the same virtual directory as the ASP page. If this is not the case,
you'll get an error. If your ASP page is in
c:\inetpub\wwwroot\mySite\myActiveServerPage.asp
then
Server.MapPath("freight100_0a.xml")
will be the same thing as writing
c:\inetpub\wwwroot\mySite\freight100_0a.xml
If the file isn't there, it won't look anywhere else--it just fails. If you
use
Server.MapPath("/dev/freight100_0a.xml")
this means the file is located in the dev subfolder of your current virtual
directory.
As a further example, if you look in your IIS manager, you might have a web
with the URL:
http://myserver.com/foo/bar
This may be mapped to
c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar
and if in an ASP page located in "bar" you have
Server.MapPath("myXML.xml")
it will replace the virtual path with the filesystem path. So in this case,
it will return:
"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\myXML.xml"
If you use
Server.MapPath("/foo/bar/myXML.xml")
it will return the same value:
"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\myXML.xml"
If you use:
Server.MapPath("snafu/myXML.xml")
then it's going to assume there is a sub folder called "snafu" in the "bar"
folder. In this case:
"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\snafu\myXML.xml"
maps to:
http://myserver.com/foo/bar/snafu/myXML.xml
If there file isn't there, you get an error. It won't search subfolders, or
any other place at all.
Regards,
Mike Sharp
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
