PRB: Site Stager Outputs ASP Results on CMS 2001 Server (302066)



The information in this article applies to:

  • Microsoft Content Management Server 2001, when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000 SP2
  • NCompass Resolution 4.0, when used with:
    • the operating system: Microsoft Windows NT 4.0
    • the operating system: Microsoft Windows 2000 SP2

This article was previously published under Q302066

SYMPTOMS

When the CMS 2001 Site Stager processes a posting that contains Active Server Pages (ASP) script, Site Stager outputs the results on the CMS 2001 server. In other words, the ASP script is not in the staged site.

RESOLUTION

To resolve this problem, make sure that the staging process preserves the scripting code. To do this, do either of the following:
  • Wrap the code with the ASP logic (AutoSession.IsModeStaging) and use Response.Write to manually output the ASP scripting tags and codes. The following sample code tests to determine whether CMS is running in Execution mode. If CMS is in Staging mode, the code that is to be preserved during staging (as stored in the myscript variable) is written out, and will be in the staged site. If CMS server is not in Staging mode, the code is run as usual.

    NOTE: This code sample assumes that you are running the VBScript engine on the IIS server.
    Dim strStaging
    Dim strDynamic
    
    strStaging = "Response.Write(""The code I want"")"
    strDynamic = "The code I want"
    
    If AutoSession.IsModeStaging Then
       Response.Write("<" + "%" + strStaging + "%" + ">") 
    Else
       Response.Write strDynamic
    End If
    					
  • Wrap the code with the CMS Site Stager staging tags. This is the recommended method because it automatically preserves all of the ASP coding logic within the tag wrapper (so that the the template designer does not have to write out "<%" manually with a separate Response.Write statement).

    In the following sample code, CMS Site Stager staging tags are used to stage ASP script. Any code that is between the STAGE_SCRIPT tags is staged without being parsed.

    NOTE: This code sample assumes that you are running the VBScript engine on the IIS server.
    <!-- RESX STAGE_SCRIPT -->
    <%
    Response.Write "The code I want"
    %>
    <!-- /RES STAGE_SCRIPT -->
    					
    Everything that is between the tags is copied intact to the staged output. Because the content that is between the tags is not validated, you can put anything between the tags.
Be aware of the following when you are using staged script:
  • The default scripting language of the template must be Visual Basic Scripting Edition (VBScript) unless a script directive (such as %@LANGUAGE=JScript %>) is placed at the top of the script.
  • If the staging tags are not specified correctly as shown in the product manual or the sample code that is presented in this article, they do not function properly and the ASP scripts are not preserved in the staged output files.
  • The staged script should not access the CMS 2001 Publishing API.
  • The default extension of the staged file is .asp unless you specify otherwise.
  • Staging tags and script that is to be staged cannot be nested inside a set of scripting delimiters.
  • You should enclose the script to be staged in a pair of scripting delimiters.

MORE INFORMATION

ASP script staging functionality is built-in, but you must enable it.

REFERENCES

For more information on CMS Site Stager tags, see "Chapter 10: Developing for MSCMS 2001 Site Stager" at the following Microsoft Web site: For more information, see the following Knowledge Base articles:

313215 INFO: Only 1 Space Allowed Around the RESX STAGE_SCRIPT Staging Tags

313246 INFO: VBSCRIPT Must Be All Caps When You Use RESX RUN_AND_STAGE_SCRIPT LAN='VBSCRIPT'


Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kbprb KB302066