Correctly handle the fault-tolerant mechanism in ASP Dynamic Web pages

Source: Internet
Author: User
Dynamic | fault-tolerant | Web page with the most popular ASP as an example, I do not know how many people will be in the code to think of the "fault tolerance" concept, in fact, when I encountered such a thing, but also nothing. Why, think about the original idea of thinking that writing code like this would be a fault-tolerant, as shown in example 1-1.
<%@ Language=vbscript%>
<%option explicit%>
<%
' ERROR filtering
On Error Resume Next
............... (Code slightly)
%>
Example 1-1 Common code glimpse

The above code often appears in the hands of fellow colleagues, needless to say the reason, I finished can understand you now mood, I can tell you frankly, I wrote two years of ASP page, most of this way, constantly write, constantly change, burnout, now do not want to go back to rewrite their own code. In fact, the idea of the most basic fault-tolerant mechanism is not to believe that the program can save you much, it is necessary to control the power in their own hands.
<%@ Language=vbscript%>
<%option explicit%>
<%
'========================================
DIM ndebug_msg
Ndebug_msg=true
IF ndebug_msg = TRUE THEN
' ERROR filtering
On ERROR RESUME NEXT
End IF
' ===============end =====================
............... (Code slightly)
' Data transaction processing-start
If Err.Number = 0 Then
' ~~~~~ Open database and BEGIN TRANSACTION ~~~~~~~~~~~~~~~~~~~~
'------------------------------
'-------------------------------------
Objconn.begintrans
objConn.Execute (Objsql)
' ~~~~~~ Commit the transaction and close the database connection
Objconn.committrans
Response.CacheControl = "Private"
Response.Expires =-1
............... (Code slightly)
Else
' ~~~~~ Rollback transactions and close objects
Objconn.rollbacktrans
' ~~~~~ Raise Errors for ASP page
' Err.Raise Err.Number, Err.Source, Err.Description
' Err.Clear
Response.Write "Description= (" & Err.Number & "), (" & Err. Description & ")"
End If
' ==============end files=====================
%>

Example 1-2 complete fault-tolerant mechanism code example

Read the above code, you will find that there is no superb skills in the inside, the master may be dismissive. But you may not be able to do this when writing code.

"1-1" When writing dynamic Web pages, must consider fault-tolerant mechanism, such as in the ASP, you should refer to example 1-2, write robust code.



Related Article

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.