Copied to clipboard

Flag this post as spam?

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


  • Lokesh kumar Chippada 44 posts 249 karma points
    Nov 10, 2015 @ 13:12
    Lokesh kumar Chippada
    0

    Errors in Razor after upgrade from 2.0 to 3.0 and MVC3 to MVC 5

    Upgraded from version 4 to 7.3.1 successfully but some macros not working

    Here is debug trace

        umbracoMacro    Executing Macro Script (file: Left Side Menu)   7.150103    0.000010
        umbracoMacro    Error Loading Razor Script (file: Left Side Menu) 'umbraco.MacroEngines.DynamicXml' does not contain a definition for 'Items'    at CallSite.Target(Closure , CallSite , Object )
          at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
          at ASP._Page_macroScripts_LeftSideMenu_cshtml.Execute() in \macroScripts\LeftSideMenu.cshtml:line 6
          at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
          at System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors)
          at System.Web.WebPages.WebPage.ExecutePageHierarchy()
          at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
          at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer)
    
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
    

    Looks like Razor script error after upgrading to latest version of MVC.

    Please let me know if anyone knows how to fix it.

    Thanks, Lokesh

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 10, 2015 @ 13:26
    Dennis Aaen
    0

    Hi Lolesh,

    Try to see this issue from the issue tracker http://issues.umbraco.org/issue/U4-3560

    Umbrage 7 donĀ“t support officially MVC 5 due to breaking changes and current incompatibility with Examine.

    However since 7.2.2 you CAN upgrade to MVC5 using Microsoft's upgrade guidelines: http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

    Hope this helps,

    /Dennis

  • Lokesh kumar Chippada 44 posts 249 karma points
    Nov 10, 2015 @ 13:34
    Lokesh kumar Chippada
    0

    Hi Dennis,

    Thanks for your quick response

    But from version 7.3.0 MVC5 is default as per this issue tracker http://issues.umbraco.org/issue/U4-6903

    Thanks, Lokesh

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 10, 2015 @ 13:41
    Dennis Aaen
    0

    Hi Lokesh,

    Oh my bad, I totally forgot this sorry for that.

    /Dennis

  • Lokesh kumar Chippada 44 posts 249 karma points
    Nov 10, 2015 @ 13:43
    Lokesh kumar Chippada
    0

    Hi Dennis,

    Do you have any idea on how to fix this 'umbraco.MacroEngines.DynamicXml' does not contain a definition for 'Items' at CallSite.Target(Closure , CallSite , Object

    That script file working fine with older version of Razor but not with the newer version

    Please let me know

    Thanks, Lokesh

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Nov 10, 2015 @ 14:25
    Dennis Aaen
    1

    Hi Lokesh,

    I have talked to one from the core team, and we have not seen this issue before. We would like to see if we can replicate it to see what the issue might be.

    Could you please provide us the exact steps that you have taken, so we can try replicate it on a clean version of 7.3.x

    /Dennis

  • Lokesh kumar Chippada 44 posts 249 karma points
    Nov 10, 2015 @ 15:02
    Lokesh kumar Chippada
    0

    Hi Dennis,

    I have upgraded website from 4.11.8 to 7.3.1, then fixed some razor issues.

    As the Razor parser of MVC5 is different from MVC3. Razor v3 is having advanced parser features and on the other hand strict parsing compare to MVC3.

    I ran into syntax errors in view while converting MVC3 to MVC5 as we have not used razor syntax in correct manner.

    I fixed some issues by avoiding server blocks in views unless there is variable declaration section.

    And also by avoiding @ when you are already in server scope.

    Example:
    @{int a = @Model.Property } to
    @{int a = Model.Property }
    

    I don't know why this script is not working

    @inherits umbraco.MacroEngines.DynamicNodeContext
        @{
            var homeNode = Model.NodeById(1116);
            if (homeNode.HasProperty("leftSideMenu")) 
            {   
                if (homeNode.leftSideMenu.Items.Count > 0)
                {
                    if (Model.HasProperty("useLeftSideMenu"))
                    {
                        if(Model.useLeftSideMenu)
                        {
                                <span class="sidebarheading">Residents</span>
                                <ul>
                                @foreach(var link in homeNode.leftSideMenu.Items)   
                                {   
                                    <li>
                                        <a href="@link.Url"@Html.Raw(link.NewWindow ? "target=\"_blank\"" : "")>@link.Title</a></li>
                                }
                            </ul>
                        }
                    }
                }
            }
        }
    

    Thanks and Regards, Lokesh

  • Lokesh kumar Chippada 44 posts 249 karma points
    Nov 10, 2015 @ 15:44
    Lokesh kumar Chippada
    0

    After digging in to code, i found that @Model.NodeById is obsolete, and i need to use @Library.NodesById"

    Thanks Dannis for your help

  • Arjun Singh 15 posts 86 karma points
    Mar 06, 2018 @ 10:42
    Arjun Singh
    0

    Hi Lokesh / Dennis,

    This issue comes when we upgrade from version 6 to 7.

    To resolve this issue , you have to check the data type of the existing node type that the picker is using.

    umbraco 6 uses the custom data type created by uComponent which is deprecated in version higher than 7.

    Just replace the respective picker with MultiNode Tree picker in Umbraco 7 , that will help in resolving the issue.

    You can get the list of available list of Data Types supported by Umbraco 7 , in Developer section when you login as Admin.
    

    Just create new data type with Multinode Tree Picker and use it to replace with the existing content property.

    Dynamic Xml will be converted to DynamicNodeList and your life is easy :)

    Thanks , let me know for any further queries. i have successfully upgraded version 6 to 7 of very Huge banking site.

    Regards, Arjun Singh

Please Sign in or register to post replies

Write your reply to:

Draft