Copied to clipboard

Flag this post as spam?

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


  • Corné Strijkert 80 posts 456 karma points c-trib
    Dec 07, 2015 @ 14:49
    Corné Strijkert
    0

    Inline Razor Macros in templates not working

    Hi all,

    After upgrading my Umbraco from v6 to v7 all inline razor script macros are broken, independent on what the content is, for example this dummy macro:

    <umbraco:Macro runat="server" Language="razor">
    @{
        var href = "index.htm";
        <a href="@href">Home</a>
    }
    </umbraco:Macro>
    

    The error:

    Error loading MacroEngine script (file: )
    

    Does somebody know a solution for this?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 07, 2015 @ 15:09
    Dennis Aaen
    0

    Hi Corné

    Are you running in MVC mode then try to do like this.

    @{
        var href = "index.htm";
        <a href="@href">Home</a>
    }
    

    Hope this helps,

    /Dennis

  • Corné Strijkert 80 posts 456 karma points c-trib
    Dec 07, 2015 @ 15:19
    Corné Strijkert
    0

    In umbracoSettings.config the render mode is set to MVC:

    <defaultRenderingEngine>Mvc</defaultRenderingEngine>
    

    Then, my macro is inside an old school contentplaceholder:

    <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
    </asp:Content>
    

    When i remove the <umbraco:Macro runat="server" Language="razor"> the Razor is outputted as HTML instead of that it is rendered as Razor.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 07, 2015 @ 15:30
    Dennis Aaen
    0

    Hi Corné,

    Okay so you are using MVC, what you need to do then is convert the old Master templates to MVC views.

    Try to see this cheatsheet on how.

    https://our.umbraco.org/documentation/Cheatsheets/masterpagestoviews

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft