Hi,
I have used ASP off and on for a few years, but now I'm really hunkering down to understand its mechanics.
I'm having trouble understanding why to use Server.MapPath.
I have all of the "textbook" defintions and in general it does make sense that you would need to map a virutal path to a physical directory (so you know where to look for files).
Here's a couple of the definitions I have:
The Server.MapPath method can be used to map a virtual path to the physical directory on the server. This method is mostly used when you are working with files. It does not check whether the file that, you provided exists or not.
Ok. Another definition is "server.mappath is used to map a virtual path to the physical directory on the server".
But these definitions still do not tell me WHY to use server.mappath.
I did the following to test it out:
This file doesn't exist.
The results I got were:
c:\inetpub\ (I ran this template containing this code in the root dir.)
I have a couple of problems with this:
This file doesn't exist in any of my root directories (I know mappath doesn't tell you whether or not the file exists).
But is this a better explanation of server.mappath (in layman's terms)? Server.MapPath simply specifies a physical directory for a filename you're intending to use. It explicitly states where to look for files.
Because in essence, aren't you just really saying "here's the path to use", and doesn't that path "default" to your root directory (or whatever directory your present template is in)? or in my case c:\inetpub\ Unless you specify otherwise?
Thanks to anyone who can provide more insight or examples for the usage of Server.MapPath.
Thanks in advance,
soho34
I have used ASP off and on for a few years, but now I'm really hunkering down to understand its mechanics.
I'm having trouble understanding why to use Server.MapPath.
I have all of the "textbook" defintions and in general it does make sense that you would need to map a virutal path to a physical directory (so you know where to look for files).
Here's a couple of the definitions I have:
The Server.MapPath method can be used to map a virtual path to the physical directory on the server. This method is mostly used when you are working with files. It does not check whether the file that, you provided exists or not.
Ok. Another definition is "server.mappath is used to map a virtual path to the physical directory on the server".
But these definitions still do not tell me WHY to use server.mappath.
I did the following to test it out:
Code:
<%
response.write server.mappath("inc1mf.asp")
%>
This file doesn't exist.
The results I got were:
c:\inetpub\ (I ran this template containing this code in the root dir.)
I have a couple of problems with this:
This file doesn't exist in any of my root directories (I know mappath doesn't tell you whether or not the file exists).
But is this a better explanation of server.mappath (in layman's terms)? Server.MapPath simply specifies a physical directory for a filename you're intending to use. It explicitly states where to look for files.
Because in essence, aren't you just really saying "here's the path to use", and doesn't that path "default" to your root directory (or whatever directory your present template is in)? or in my case c:\inetpub\ Unless you specify otherwise?
Thanks to anyone who can provide more insight or examples for the usage of Server.MapPath.
Thanks in advance,
soho34