ASP Server Object
By Stephen Bucaro
The Server object provides access to properties and methods on the server. The Server object
MapPath method maps a website path to a physical server path.
The example below uses the server variable PATH_INFO to map the physical path of the current file.
Server.MapPath(Request.ServerVariables("PATH_INFO"))
If C:\Inetpub\Wwwroot is the server's home directory, the above statement will return:
C:\inetpub\wwwroot\script\test.asp
The example below starts the path parameter with a slash character to specify that the
path returned should be as complete virtual paths on the server.
Server.MapPath("/script/test.asp")
If C:\Inetpub\Wwwroot is the server's home directory, the above statement will return:
C:\inetpub\wwwroot\script\data.txt
Because the path parameter in the following example does not start with a slash character,
it is mapped relative to the directory that contains the file.
Server.MapPath("data.txt")
• In IIS 6 or higher, for security reasons, the AspEnableParentPaths property
has a default value set to FALSE. Scripts will not have access to the physical directory
structure unless AspEnableParentPaths is set to TRUE.
Property | Description |
ScriptTimeout | ScriptTimeout sets the maximum amount of time
(in seconds) that the script on the page can run before it is terminated.
The default value is 90 seconds. |
Method | Description |
CreateObject | CreateObject creates an instance of the object (component,
application or a scripting object) and returns a reference to it. Once created, the object's
properties and methods can be used. |
Execute | Execute runs another .asp page without leaving the current page.
It stops execution of the current page and transfers control to the specified page. When
that page has completes execution, control passes back to the calling page. |
GetLastError | GetLastErrorreturns an ASPError object that describes the
error condition that occurred. |
HTMLEncode | HTMLEncode applies HTML encoding to a specified string. All
not valid characters are converted to their equivalent HTML entity. |
MapPath | MapPath maps a specified virtual or relative path to a physical
path on the server. |
Transfer | Transferstops execution of the current page and sends all current
state information to another specified page. When that page has completes execution,
control does not resume with the calling page. |
URLEncode | URLEncode applies URL encodingto a specified string. All
characters that are not valid in a URL string are converted to their equivalent HTML entity. |
|