Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jdelagoutte 13 posts 26 karma points
    Oct 06, 2010 @ 17:43
    jdelagoutte
    0

    Stopping page rendering

    Hi, 

     

    I would like to stop the rendering of a page after a test. Something like :

    in the template

    <umbraco:Macro Alias="CheckSecurity" runat="server"></umbraco:Macro>
    <umbraco:Macro Alias="RenderPage-Part1" runat="server"></umbraco:Macro>
    <umbraco:MAcro Alias="RenderPage-Part2" runat="server"></umbraco:macro>

    The idea is that the macro CheckSecurity will make some tests, and stop the rendering if some conditions are false (not allowed alttemplate, for example). Then the two following macros should be executed.

    I plan to use something like:

    <xsl:if test="my false condition">
        <xsl:value-of select="myLibrary:FlushAndEndResponse()"/>
    </xsl:if>

    and an xslt extension like :

    public static void FlushAndEndResponse()
    {
        System.Web.HttpContext.Current.Response.Flush();
        System.Web.HttpContext.Current.Response.End();
    }

    But I end up with an error 

    Thread was being aborted.
      
    at umbraco.macro.loadMacroXSLT(macro macro, Hashtable attributes, Hashtable pageElements)

      at umbraco.macro.renderMacro(Hashtable attributes, Hashtable pageElements, Int32 pageId)

      at umbraco.presentation.templateControls.Macro.CreateChildControls().

     

    Has anyone done something like this in the past?

    I'm still on V4.0.3. 

     

    Thanks

  • Sascha Wolter 615 posts 1101 karma points
    Oct 06, 2010 @ 18:40
    Sascha Wolter
    0

    How about setting some kind of application variable (cache, session, ...) in the first macro and check for that in the other macros, if condition false then don't do anything in the macros? Haven't tried yet to end the response this way yet, however might actually be a bit tricky this way as you don't always have a clean state/linear workflow (e.g. multi threading).

    Cheers,

    Sascha

  • jdelagoutte 13 posts 26 karma points
    Oct 12, 2010 @ 16:19
    jdelagoutte
    0

    Thanks a lot for this response.

    But, I was planning to use this to prevent using a wrong alttemplate on every document. If I want to apply your solutionn  I have to add this check in every macro.

    I was planning to add this check only as the first macro of the upper master template.

Please Sign in or register to post replies

Write your reply to:

Draft