Previous in Contents Next in Contents

Run Method

This method generates the CDF string representing the user's personal channel selections. It then directly sends the string to the client browser via the built-in ASP Response object with the Multipurpose Internet Mail Extensions (MIME) type set to "application/x-cdf." In essence, the ASP page becomes a dynamic CDF file containing the user's personalized channel content.

VBScript Syntax

ICDFGenerator.Run CDFGenHelperName

Parameters

CDFGenHelperName

A string specifying the key indexing a class CDFGenHelper object in the ASP Application collection.

Return Value

None

Remarks

The CDFGenHelperName string passed must be the "key" under which a valid CDFGenHelper interface is indexed in the ASP application's Application collection. If the object cannot be found in the Application collection, the Run method will fail.

The Run method will also fail if the class Server object did not create the instance of the CDFGenerator class, because the UserObjects object will not have been properly instantiated.

Examples

The following example first lists a hypothetical Application_OnStart subroutine located in an ASP application's Global.asa file. The subroutine creates an instance of a CDFGenHelper class and then loads a given Project object. It then adds the object to the ASP Application collection, making it available to other ASP pages within the application scope. The next example lists the contents of a hypothetical ASP page located within the application's scope (that is, either in or below the virtual directory that contains the Global.asa file). The script creates an instance of the CDFGenerator class that generates the current user's personalized CDF string. It passes the Application "key" name of the CDFGenHelper object as an argument to the Run method. Behind the scenes, the object uses the resident UserObjects object to retrieve the user's list of selected channel GUID values that are stored in the Membership directory service under the user property specified by Project.SelectionListPropName. The Project.SelectionStylePropName optionally is checked to supply the "style" of the list (that is, whether the list is of channels to include or exclude from the project). The list and style are then passed to the CDFGenHelper object, and the personalized CDF string is returned. The string is then sent as the response to the user's request with the appropriate MIME-type.

Following is an excerpt from a Global.asa file:

<SCRIPT LANGUAGE="VBSCRIPT" RUNAT="SERVER">
Sub Application_OnStart ()
  ...
  Set ICDFGenHelper = CreateObject("Push.CDFGenHelper")
  ICDFGenHelper.Load "Project1"
  Set Application("GenHelperProject1") = ICDFGenHelper
  ...
End Sub
...
</SCRIPT>

An ASP sample script

<% 
   Set ICDFGenerator = Server.CreateObject("Push.CDFGenerator")
   ICDFGenerator.Run "GenHelperProject1"
%>

The following example illustrates what happens in the ASP script listed above behind the scenes. However, this approach is not recommended, as it would severely degrade server performance. It is presented strictly to outline the complete process encapsulated by the CDFGenerator methods, as well as facilitate debugging.

<%
   Response.Buffer = True

   '  this step is done in CDFGenerator.OnStartPage method
   Set AUO = Server.CreateObject("Membership.UserObjects")

   
   '  The run method does the following

   '  Get the dispinterface to the CDFGenHelper object
   Set PushPrjHelper = Application("GenHelperProject1")

   '  fetch the property names that store channel
   '  channel selections from the project
   PushPrjHelper.GetSelectionListPropName( ListPropName, StylePropName )
   
' get the list of channel GUIDs, and optionally, the style
' of the list
   ChannelList = AUO.Get ListPropName   ' fetch the list
   ListStyle   = AUO.Get StylePropName  ' fetch type of list

   '  Get the CDF string using the returned list and send it to
   '  the built-in ASP Response object

   call PushProject.GetCDFString(ChannelList, ListStyle, Response.Write)

   '  Set the outgoing MIME type explicitly
   Response.ContentType = "application/x-cdf"
   Response.End
%>   

See Also

Class UserObjects (Membership.UserObjects)


© 1997-2000 Microsoft Corporation. All rights reserved.