The Server| Object Server object provides methods and properties that are accessed on the server. Most of the methods and properties are provided as functionality of the utility.
Grammar:
Server.property|method
Properties (property)
The server object has only one property: The maximum time a scripttimeout program can run
Method (Methods)
CreateObject establishes an object instance.
Execute executes an ASP file
GetLastError returns an error code
HTMLEncode converts the specified HTML code.
MapPath converts a relative path to an absolute path.
Transfer sends all current status information to another ASP file
UrlEncode converts the specified code, including spaces, as a URL
Method details of the server object
CreateObject
Grammar
Server.CreateObject (ProgID)
Parameters
ProgID
Specifies the name of the component to be created, in the following format: [Vendor.] component[. Version].
Points:
In general, objects created by the Server.CreateObject method have a range of pages. This means that when this page's ASP program is finished, this object will automatically disappear.
To create an object that has a session or application range, you can use the Global.asa file in the
Execute
The Execute method calls an ASP file and executes it just as the ASP file for this call exists in this ASP file. This is much like a call to a class in many languages.
Grammar
Server.Execute (Path)
Parameters
Path
Specifies the path to the ASP file that is executed. If it is an absolute path, then it must be in the same place as the ASP application (directory).
Explain
The Server.Execute method provides a way to divide a complex ASP application into small units. In this way, you can build an ASP library, and you can call the ASP files in your library whenever you need them. This is kind of like SSI! Hey!
When IIS finishes executing the ASP file based on the specified ASP file path, the previous ASP file is automatically returned. The ASP file that has just been executed may have changed the HTTP head. But as with other ASP files, when the program tries to change the HTTP head, it complains!
This path parameter can include a query information.
If you have the same child functions in the ASP files that are called and called, these child functions only work in this ASP file. For example, if you have a child function that discards a program in the following ASP1 and ASP2 two files. First ASP1 call ASP2, then the OnTransactionAbort in ASP2 begins execution, and ASP2 in ASP1 begins execution when OnTransactionAbort executes.
ASP1:
%@ transaction=required%>
%
Server.Execute ("page22.asp")
Sub OnTransactionAbort
Sub OnTransactionCommit
%>
Asp2.asp:
%@
Transaction=required
Sub OnTransactionAbort
Sub OnTransactionCommit
%>
Example
ASP1
% Response.Write ("I am going to execute ASP2")
Server.Execute ("/myasps/asp2.asp")
%>
ASP2
% Response.Write ("Here I am")%>
GetLastError
The GetLastError method returns a ASPError Object to describe an error message. This method only works before the ASP file sends any content to the user machine.
Grammar
Server.GetLastError ()
Points
If a 500;100 user error has been defined in an ASP application, it refers to a file with an. asp suffix. In this case, when an error occurs while the program is running, the server is automatically routed to the executing ASP page in Server.Transfer. The ASP application will effectively handle this error. In addition, this ASPError object must be valid so that you can see the error message provided by the server to change the file!
The general web Site is constructed from file \iishelp\common\500-100.asp. You can use it to execute an ASP error, of course you can define it yourself!. If you want to change to another ASP file to perform these user errors. Then you can use the snap-in in IIS.
Note: When IIS discovers an ASP file or an error in the Global.asa file, a 500;100 user error occurs. The following programs will not execute!
Example
The following three examples demonstrate a user error that can result from a different error. Three errors are:
Compile error
Run error
Logical error
The first example demonstrates a compilation error that occurs when IIS attempts to include a file. This error occurs because the required parameters are not defined in this include file. The second example shows a run-time error, which is interrupted because there is no "next" in the program. The third example shows a logical error because the program attempts to divide by a 0. No way!
Example 1
%
Response.Write "Hello"
%>
Example 2
%
Dim I
For I=1 to 1
Nxt
%>
Example 3
%
Dim i,j
Dim sum
Sum=0
J=0
For I=1 to 10
Sum=sum+1
Next
Sum=sum/j
%>
HTMLEncode
The HTMLEncode method HTML encodes the specified string.
Grammar
Server.HTMLEncode (String)
[1] [2] [3] Next page