Accessing the ASP Built-in Objects

In IIS 3.0, components could access ASP built-in objects through the IScriptingContext interface. Components that needed to access the built-in objects did so through page-level event methods. While this is still supported, an alternative now exists and is recommended as an improvement over page-level event methods.

You can now use the ObjectContext object to access the built-in objects. ObjectContext makes IIS applications better suited for large scale scenarios and provides support for transaction processing. It is highly recommended that you convert your existing ASP-based applications to this new approach if they are high-volume applications. This conversion is required if your applications support transaction processing.

If your ASP application includes transaction processing scripts, any object instances from your component that participate in transactions must be registered with the Microsoft Transaction Server (MTS). By registering your component with MTS, you will be able to take advantage of the MTS run-time environment benefits.

In the following sample, a script calls two objects, CheckInventory and PostSale. Because both objects participate in the transaction, each must be registered with MTS.

<%@Transaction = Required%> 
Dim Quantitytocheck, Accountocheck, Invstatus, Acctstatus
   Set Invstatus = Server.CreateObject(MyObj.CheckInventory)
   Set Acctstatus = Server.CreateObject(MyObj.PostSale)
      quantityout = Response("Currentquantity")
      accountout = Response("Currentaccout")
   Set Quantitytocheck = Invstatus.checkqoh(quantityout)
      If Quantitytocheck = OKStatus 
            Set Accounttocheck = Acctstatus.postit(accountout)
        Else Context.SetAbort
      End if
%>

In the above example, MyObj.CheckInventory and MyObj.PostSale would access ASP built-in objects through the MTS ObjectContext. The following sample demonstrates accessing the Response object.

Public Function GetResponse(ByVal stringin As Variant)
   Dim curres As ObjectContext
   Set curres = GetObjectContext ()
   GetResponse = curres("Response").Write (stringin)
End Function

To see complete sample components that use ObjectContext to access the ASP built-in objects, see Developer Samples.


© 1997 by Microsoft Corporation. All rights reserved.