1

I'm getting the following exception when compiling a dynamic component presentation published as an ASCX web control:

CPAssembler error: WAIPage object not initialized. Make sure to use the ComponentPresentationAssembler constructor that accepts a WAIPage

The context is:

This is happening for an environment that is running on an IIS 7.5, attached to a web application executing on .NET Framework 4.0. The version of Tridion is 2011 and the code throwing the exception is this:

ComponentPresentationAssembler ctAssembler = new ComponentPresentationAssembler(pageId, page);

for (int i = 0; i < items.Length; i++)
{
      string output = ctAssembler.GetContent(
                  /*component TCM URI*/,
                  /*template TCM URI*/
            );

As you can see, I'm using the overload of the ComponentPresentationAssembler that provides the TCM URI of the page and the System.Web.UI.Page object. The CPs with the extension ASCX are redirected to a local folder in the executing web site. The configuration looks like this:

        <Storage Type="filesystem" Class="com.tridion.storage.filesystem.FSDAOFactory" Id="filesystem_ascx">
            <Root Path="\%Path to the web site%\cd_storage_WebControls" />
        </Storage>
    </Storages>
  </Global>
  <ItemTypes defaultStorageId="sqlserver" cached="true">
      <Item typeMapping="Page" storageId="filesystem" cached="true"/>
      <Item typeMapping="Binary" storageId="filesystem" cached="true"/>
      <Item typeMapping="ComponentPresentation" itemExtension=".ascx" storageId="filesystem_ascx" cached="true"/>
  </ItemTypes>

The output of the DCTs is being published to the above folder and it's stored in files with the ASCX extension. But I'm stuck with this exception each time I try to render one of these component presentations.

1

the page reference you are passing should be executing asp page. e.g this.Page. because your user control has to be rendered on it only.

  • Do you mean the executing System.Web.UI.Page object? – glezalex Jul 7 '15 at 7:13
  • your current asp.net page reference on which you want your presentations. – Raj Kumar Jul 7 '15 at 8:36
  • did it work or helped you? – Raj Kumar Jul 7 '15 at 16:52
1

I finally found the reason why I was getting this exception. Apparently the invokation to GetContent must be performed from a context (the page itself or a Web User Control) that has both: this.Page and HttpContext.

As I was implementing the solution, the rendering of the component presentations was performed from a separated static class without access to the HttpContext.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.