Copied to clipboard

Flag this post as spam?

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


  • Matei Dorobantu 5 posts 95 karma points
    Sep 07, 2017 @ 22:47
    Matei Dorobantu
    0

    Macro not rendering in the backoffice

    Hi all,

    I am having a strange issue with a macro not rendering in the backoffice. It used to work and it stopped suddenly and with a strange error message.

    An exception of type 'System.InvalidOperationException' occurred in umbraco.dll but was not handled in user code
    
    Additional information: Cannot return the IPublishedContent because the UmbracoHelper was constructed with an UmbracoContext and the current request is not a front-end request.
    

    It looks like the offending code is retrieving the Macro Paramaters but I do that with other macros and it works fine.

    Any ideas what might be causing this?

    Thanks!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 08, 2017 @ 09:41
    Alex Skrypnyk
    0

    Hi Matei

    What version of Umbraco are you using?

    Can you show the macro code?

    Thanks,

    Alex

  • Matei Dorobantu 5 posts 95 karma points
    Sep 08, 2017 @ 15:11
    Matei Dorobantu
    100

    Hi Alex,

    Umbraco version is 7.6.1. Here are the offending lines in the partial view:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using System.Web.Optimization
    
    @Styles.Render("/bundles/bookviewing/css")
    @Scripts.Render("/bundles/bookviewing/js")
    
    @{
        var projectNo = Model.MacroParameters["projectNo"].ToString();
    }
    

    The macro has one parameter defined projectNo which is used to drive some Javascript further down in the view.

    The workaround for now is to not render the macro in the backoffice and I think we can live with that; maybe there is something I misunderstand here about how this works so anything would help really.

    Cheers!

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Sep 11, 2017 @ 10:36
    Alex Skrypnyk
    0

    Hi Matei

    If you macro contains javascript - definitely do not render it in the backend. It can cause the unpredictable problems.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft