Accessing ASP Built-In Objects from Components

Use the COM+ ObjectContext object to access the ASP built-in objects from an application. This object implements the COM+ IObjectContext interface. The COM+ ObjectContext object provides a better and easier interface to access the ASP intrinsics. The COM+ object context also provides support for transaction processing.

Note

In older versions of IIS, components accessed the ASP built-in objects by creating an instance of the ScriptingContext object, which implemented the IScriptingContext C++ Interface. Components that needed to access the ASP built-in objects did so through Page-level Event Methods. This approach still works in order to be compatible with existing ASP applications, however, using the COM+ ObjectContext object is easier and better as mentioned above, with one exception: if you implement your component as an executable file instead of a dynamic link library, you cannot use the COM+ ObjectContext object to access the ASP built-in objects. You must use IScriptingContext C++ Interface and Page-level Event Methods.

The following code snippet demonstrates accessing the Response.Write method using the COM+ ObjectContext object in Visual Basic?(VB).

Public Function GetResponse() 
  Dim vntCurrent As Variant 
  Dim curres As ObjectContext 
  Set curres = GetObjectContext() 
  vntCurrent = curres("Response").Write ("Hello World") 
End Function 

See Also