Resolving server Objects

Source: Internet
Author: User
Tags error code iis range
The 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.





Syntax:





Server.property|method





Property




The
server object has only one property: The maximum time the 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 to a URL, including a space





the method of the server object in detail





CreateObject





Syntax





Server.CreateObject (ProgID)





parameter





ProgID





Specifies the name of the component to be created, in the following format: [Vendor.] component[. Version].





Main points:





in general, objects created by the Server.CreateObject method have a range of pages. This means that when the page's ASP program is finished, this object automatically disappears.





in order to create an object that has a session or application range, you can use
in the Global.asa file




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.





Syntax





Server.Execute (Path)





parameter





Path





specifies the path to the ASP file that executes. 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 split 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 the ASP file based on the specified ASP file path, it automatically returns to the previous ASP file. 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.





Syntax





Server.GetLastError ()





Essentials





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!





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:





compilation Error





Run Error





Logic 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 to HTML-encode the specified string.





Syntax





Server.HTMLEncode (String)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.