Copied to clipboard

Flag this post as spam?

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


  • Andrew Munro 78 posts 161 karma points
    Jan 29, 2014 @ 14:53
    Andrew Munro
    0

    Model object is null on some razor macros in 7.0.1

    We're having an issue with 2 or 3 macros while accessing the model object. After upgrading to 7.0.0, this issue affected all of our macros that attempted to use the Model object. Now, at 7.0.1, most of our macros work but there are still a couple that don't. When attempting to access the model object on a broken macro, we get the following exception

    An exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in App_Web_productpagerenderblockcontent.cshtml.70df5e80.kcpv0jez.dll but was not handled in user code

    I've tried cleaning all razor macros in the /Temp/Razor but that didn't seem to do anything.

    The line in question is this:

    @DrawColumn(Model.BlockContentContainerLeft.First().Children)
    

    DrawColumn is just a helper function defined at the top of the cshtml file as such

    @helper DrawColumn(dynamic dContentCollection)
    {
      int iLeftPaddingSize = 0;
      int ileftMarginTopPadding = 0;
      int iCount = 0;
    
      foreach (var item in dContentCollection)
      {
         
    @try { if(item.renderLeftMargin == true) { iLeftPaddingSize = item.leftMarginSize; ileftMarginTopPadding = item.leftMarginTopPadding;
    @item.leftMarginContent
    }
    @if(!String.IsNullOrEmpty(@item.blockHeader)) {

    @item.blockHeader

    } @RenderContent(item, iCount)
    } catch(Exception ex) {

    @ex.Message

    }
    iCount++; } }

    It seems to me that this problem is only affecting macros with helper functions but I havent been able to confirm that yet. 

  • Andrew Munro 78 posts 161 karma points
    Jan 29, 2014 @ 15:43
    Andrew Munro
    0

    So it seems the problem only exists for non-inline razor macros. Any macro that has a CSHTML file in "Scripting Files" cannot access the model object properly. Any thoughts?

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Feb 10, 2014 @ 00:40
    Shannon Deminick
    0

    Hi, I've replied to you here: http://issues.umbraco.org/issue/U4-2967

    If you can please create another issue and assign to me with details I'll have a look.

Please Sign in or register to post replies

Write your reply to:

Draft