Copied to clipboard

Flag this post as spam?

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


  • Kin 30 posts 172 karma points
    Feb 17, 2016 @ 19:11
    Kin
    0

    [7.3.X to 7.4.X] Html.Action fails

    Hello,

    I've been having an error since upgrading to 7.4.X (from 7.3.X). I have a SurfaceController called "Common" which basically is used to display the menu recursively until X levels have been reached.

    This worked in 7.3.X:

    PagesList (Partial)

    <ul class="side-nav" role="navigation">
                @{var children = themeHomePage.Children.Where("Visible");}
                @foreach (var child in children)
                {
                    @Html.Action("DisplayMenuNodes", "Common",
                        new {
                            currentNode = child,
                            currentPageId = Model.Id,
                            currentLevel = 0,
                            maxLevel = 1,
                            displaySection = true
                        });
                }
        </ul>
    

    CommonController (SurfaceController)

    [ChildActionOnly]
            public ActionResult DisplayMenuNodes(
                IPublishedContent currentNode, 
                int currentPageId, 
                int currentLevel, 
                int maxLevel,
                bool displaySection)
            {
                if (maxLevel != -1 && currentLevel >= maxLevel)
                {
                    return null;
                }
    
                return PartialView("MenuNodes", new MenuNodesModel(
                    currentNode, 
                    currentPageId, 
                    currentLevel, 
                    maxLevel,
                    displaySection));
            }
    

    MenuNodes (PartialView)

    @model OngletFoncier.Models.MenuNodesModel
    
    @{
        if (Model.Page.DocumentTypeAlias == "Section" 
            && Model.Page.Children.Where("Visible").Any())
        {
            if (Model.DisplaySection) { 
            <li class="header">
                <a href="javascript:void(0)">
                    @Model.Page.GetPropertyValue("title")
                </a>
                @if (Model.MaxLevel == -1 || Model.CurrentLevel + 1 <= Model.MaxLevel)
                {
                    <ul>
                        @foreach (var child in Model.Page.Children.Where("Visible"))
                        {
                            @Html.Action("DisplayMenuNodes",
                        "Common",
                        new
                        {
                            currentNode = child,
                            currentPageId = Model.CurrentPageId,
                            currentLevel = Model.CurrentLevel,
                            maxLevel = Model.MaxLevel,
                            displaySection = Model.DisplaySection
                        });
                        }
                    </ul>
                }
            </li>
            }
            else
            {
                foreach (var child in Model.Page.Children.Where("Visible"))
                {
                    @Html.Action("DisplayMenuNodes",
                        "Common",
                        new
                        {
                            currentNode = child,
                            currentPageId = Model.CurrentPageId,
                            currentLevel = Model.CurrentLevel,
                            maxLevel = Model.MaxLevel,
                            displaySection = Model.DisplaySection
                        });
                }
            }
        }
        else if (Model.Page.DocumentTypeAlias.IndexOf("Folder") == -1)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    
            <li role="menuitem" class="link@(Model.CurrentPageId == Model.Page.Id ? " current" : String.Empty)">
                <a href="@Model.Page.Url">
                    @if (Model.Page.DocumentTypeAlias == "ReusableContentPage" && Model.Page.GetPropertyValue("title") == "")
                    {
                        var reusableContent = umbracoHelper.Content(Model.Page.GetPropertyValue<int>("RCNodeId"));
    
                        @(reusableContent.GetPropertyValue("title"))
                    }
                    else
                    {
                        @(Model.Page.GetPropertyValue("title"))
                    }
                </a>
                @if (Model.CurrentPageId == Model.Page.Id)
                {
                    <span class="offscreen"> - Page courante.</span>
                }
                @if (Model.Page.Children.Where("Visible").Any()
                    && (Model.MaxLevel == -1 || (Model.CurrentLevel + 1 < Model.MaxLevel)))
                {
                    <ul>
                        @foreach (var child in Model.Page.Children.Where("Visible"))
                        {
                            @Html.Action("DisplayMenuNodes",
                            "Common",
                            new
                            {
                                currentNode = child,
                                currentPageId = Model.CurrentPageId,
                                currentLevel = Model.CurrentLevel + 1,
                                maxLevel = Model.MaxLevel,
                                displaySection = Model.DisplaySection
                            });
                        }
                    </ul>
                }
            </li>
        }
    }
    

    Yet in Umbraco 7.4.X, I get this error in PagesList (@Html.Action("DisplayMenuNodes", "Common",{...} line):

    Détails de l'exception: Umbraco.Web.Mvc.ModelBindingException: Cannot bind source type System.String to model type Umbraco.Core.Models.IPublishedContent.

    What changed that it wouldn't work?

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 18, 2016 @ 11:51
    Jeroen Breuer
    0

    Hello,

    Did you try Umbraco 7.4.1? Some issues related to this have been fixed.

    Jeroen

  • Kin 30 posts 172 karma points
    Feb 18, 2016 @ 15:36
    Kin
    0

    Yes, same error in 7.4.1.

  • Joe Price 4 posts 24 karma points
    Feb 18, 2016 @ 16:25
    Joe Price
    0

    Hi, I am getting the same problems with using

    @Html.Action("Header", "Global", new { content = Model.Content })

    I get the following error: Cannot bind source type System.String to model type Umbraco.Core.Models.IPublishedContent.

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 18, 2016 @ 17:10
    Jeroen Breuer
    0

    Hmm if it's a bug you can report it here: http://issues.umbraco.org/newissue

  • Joe Price 4 posts 24 karma points
    Feb 18, 2016 @ 17:17
  • Dan Lister 416 posts 1974 karma points c-trib
    Feb 19, 2016 @ 12:25
    Dan Lister
    0

    I'm also getting this issue. Yet to find the cause or work around. Thanks for raising a bug.

    Dan.

  • Daniel Chenery 119 posts 465 karma points
    Feb 19, 2016 @ 15:32
    Daniel Chenery
    0

    Same issue here, thanks for raising the issue :)

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Feb 22, 2016 @ 17:50
    Sebastiaan Janssen
    1

    There's an update on that issue and a dll you can test http://issues.umbraco.org/issue/U4-8030

    We're not super sure about the fix yet, but it should alleviate the issue for now until we have a final fix.

  • Daniel Chenery 119 posts 465 karma points
    Feb 23, 2016 @ 09:53
    Daniel Chenery
    0

    I can confirm this works for me too :)

    Thanks for the speediness on this! 👍

  • Kin 30 posts 172 karma points
    Feb 22, 2016 @ 18:17
    Kin
    0

    Thank you for the fix. I'll try it sometime this week.

  • Joe Price 4 posts 24 karma points
    Feb 23, 2016 @ 07:41
    Joe Price
    0

    Thanks for the fix. I can confirm this works.

  • Niels Lynggaard 193 posts 551 karma points
    Mar 07, 2016 @ 08:47
    Niels Lynggaard
    0

    I have the same issue, I will grab the dll. Hope we can have a new release with the fix soon. Thanx !

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Mar 07, 2016 @ 09:21
    Sebastiaan Janssen
    100

    We're doing our regular monthly release cycle, so thursday next week 7.4.2 should be out with a fix in it.

  • Niels Lynggaard 193 posts 551 karma points
    Mar 07, 2016 @ 14:50
    Niels Lynggaard
    0

    Awesome, looking forward! I can confirm that the posted build solved this for me. However, it refuses to save my true/false properties on any pages, wich is quite annoying, since my solution relies heavily on these.. I'll test it on a clean, new install and report it if the newest published package also does this..

  • Niels Lynggaard 193 posts 551 karma points
    Mar 07, 2016 @ 15:33
    Niels Lynggaard
    0

    After testing this again, I must say that the pre-release has a bug in relation to saving the value of true/false properties. It simply doesn't seem to care one bit about them... But This is off cource a pre-release build, but others out there fixing the posted bug with this pre-release must be aware of this...

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Mar 08, 2016 @ 07:54
    Sebastiaan Janssen
    0

    @Niels got example code? is this a surfacecontroller or..? not sure what you mean?

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Mar 08, 2016 @ 08:05
    Sebastiaan Janssen
    0

    Never mind, I can reproduce the problem with true/false fields, thanks for reporting! Not related to this fix but certainly a bad bug! We're working on it.

  • Kin 30 posts 172 karma points
    Mar 08, 2016 @ 16:54
    Kin
    0

    I see the fix will roll out in 7.4.2.

    Thank you for your quick work.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies