Late SXML Execution from ASP.NET Pages

Release 1.0 - ...

It is very simple to store ASP.NET logic in the CMS. It can even be generated using all Smartsite SXML logic you can think of.

To make ASP.NET execute the resulting iXperion-rendered output, we can use the iXperion Virtual Path Provider, by referencing the pages using the configured VirtualPathPrefix in the smartsite.config file:

HTML CopyCode image Copy Code
http://yoursite/cmsvp/def/youraspnetitemcode.aspx

Now, you'll have to realize the fact that dynamic SXML instructions in Virtual Cms files are executed when the virtual file is read by ASP.NET: the resulting output of the iXperion Publication Engine being an ASP.NET file that has no SXML code (if it would, the ASP.NET rendering engine would complain!).

This is where the ASP.NET cms:region webcontrol comes to the rescue. This control can be used as a wrapper for SXML code to be executed by Smartsite dynamically from ASP.NET (after compilation).

HTML CopyCode image Copy Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="/members/Login.aspx.cs" 
 Inherits="Members_Login" MasterPageFile="/cmsvp/def/aspnetmaster.master" %>
<asp:Content runat="server" ContentPlaceHolderID="BodyPlaceholder">
 
 [your asp.net logic]
 
  <div class="menubar">
    <!-- Let smartsite iXperion render some links! -->
    <cms:region runat="server">
      <se:xlinks parent="mymenufolder" />
    </cms:region> 
  </div>
 
</asp:Content>

A pretty easy way to combine ASP.NET and Smartsite business logic.

So here we are, just encapsulate the SXML you wish to have executed dynamically in your ASP.NET pages in cms:region tags. Problem solved!

Not exactly...

Some issues with this approach remain:

  • The code as shown above is not valid for the SXML processor, so we need to escape it in the Smartsite Cms and then unescape it when served as file data to the ASP.NET environment to be executed there.
  • Site builders would have to go through the tedious process of encapsulating all SXML logic that needs to still be dynamic at ASP.NET runtime.
  • Re-using code defined in RenderTemplates and Translations for both Smartsite pages and ASP.NET pages would be very hard, since the ASP.NET tags willget in the way of normal Smartsite processing.

The solution

To remove the complexity for Site Builders, The Region macro provides a simple and elegant model, through the RunMode parameter:

Smartsite SXML CopyCode image Copy Code
<se:region runmode="auto">
  <se:xlinks parent="mymenufolder" />
</se:region>

The RunMode parameter (Enum)has the following values:

  • Internal (default)
    Region renders normally.
  • External
    Regionmacro emits an escaped code block for ASP.NET.
  • Auto
    Depending onwhether the macro is executed while in a Virtual Path Provider request, internal or externalrendering is chosen.

Conclusion

Hybrid solutions with ASP.NET applications using the Smartsite Publication Engine to generate ASP.NET Pages have become easier than ever.

The complexity of having dynamic SXML executed from a compiled ASP.NET Page is reduced to merely setting a property of the Region macro.