ALP Server.MapPath method
Maps a virtual or relative path to a physical path.


x = Server.MapPath( string )


string - string containing the path to be translated

The method returns new string containing the physical path corresponding to the path (virtual or relative) in the passed parameter (see Syntax for details).



<%= Server.MapPath("/databases/database1.mdb") %>

Using this method the ASP page can be made portable without need of reconfiguration. On the WEB servers applications are not moved frequently and need of that method is not so important but scripts executed by the ALP need much more portability thus we recommend to use the MapPath method in any place where the path to a resource is required.  This implies that packing all the files that may be needed by the application in a single Virtual ALP site is the best approach. 


Passed parameter can contain full virtual path - relative to the root of the Virtual ALP site or relative path - relative to the directory containing the calling page.

Lets get an example environment - ALP site in the subtree of the C:\site, and script in the C:\site\scripts\script.asp. The script wants to use (somehow) a file located in the C:\site\scripts\dir1\file.some. It calls MapPath with a relative path:


This returns: C:\site\scripts\dir1\file.some

Script also can call the MapPath with full virtual path:


That will produce the same result. If the ASP script uses some include files or if the raw ScriptGen script uses some libraries Server.MapPath called in these files will assume the context/location of the executed script not the location of the included file. It is appropriate to use the MapPath in the include/library script files only with full virtual paths - in other case result of the mapping will differ depending on the script that is executed and includes that include file/library. As an exception sometimes this technique (passing relative path to MapPath in the include file) can be useful to allow different scripts using the same include file access different resources - i.e. your site probably contains several branches/sub-trees with similar structure but with different files.


Using MapPath with relative paths depends on the (int)EnableParentPaths value in the alp.application specified in sections managed by the ScriptGen content generator. If its value is 0 or the value not present MapPath will rise an exception if the passed parameter contains ".." characters - i.e. accesses parent paths. See also the ALP Settings shell extensions.

Applies to: Server object

See also: ASP page structure, ScriptGen configuration

newObjects Copyright 2001-2006 newObjects [ ]