Copied to clipboard

Flag this post as spam?

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


  • Matt 158 posts 389 karma points
    1 week ago
    Matt
    0

    Umbraco error on published files

    Hello all,

    So I've been working on a website on my local machine, everything is working perfect.

    However I've now uploaded it to a VPS and published all the files and now I keep getting the following error;

    The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel1[Umbraco.Web.PublishedContentModels.Home]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[Cogworks.Meganav.Models.MeganavItem]'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel1[Umbraco.Web.PublishedContentModels.Home]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[Cogworks.Meganav.Models.MeganavItem]'.

    Source Error:

    Line 32: @{ Line 33: var homeNode = Model.Content.Site().OfType

    I'm not sure whats going on as it works fine on my local machine?

    Thanks

  • Matt 158 posts 389 karma points
    1 week ago
    Matt
    0

    Anyone got an ideas what I'm missing??

  • Dave Woestenborghs 3159 posts 10354 karma points MVP 3x admin c-trib
    1 week ago
    Dave Woestenborghs
    0

    Hi Matt,

    It looks like you are using Models builder and something is wrong with your generated models.

    Can you have a look in the developer section and go to the models builder dashboard and see how it is configured.

    Dave

  • Matt 158 posts 389 karma points
    7 days ago
    Matt
    0

    Hello Dave,

    Thanks for reply here is my models builder dashboard;

    ModelsBuilder is enabled, with the following configuration

    •The models factory is enabled.

    •The API is neither installed nor enabled. External tools such as Visual Studio cannot use the API.

    •PureLive models are enabled.

    •Models namespace is Umbraco.Web.PublishedContentModels.

    •Static mixin getters are enabled. The pattern for getters is "Get{0}".

    •Tracking of out-of-date models is not enabled.

  • Dave Woestenborghs 3159 posts 10354 karma points MVP 3x admin c-trib
    6 days ago
    Dave Woestenborghs
    0

    Hi Matt,

    I think it has to do with security settings on your VPS.

    Modelsbuilders in PureLive mode needs to be able to run the roslyn compiler (the exe files in \bin\roslyn)

    What you can on your local machine is change the Modelsbuilder mode to "Dll" in the web.config file.

    After that go in Modelsbuilders dashboard again and click the "Generate Models" button.

    After that transfer your local bin folder and web.config (or change the one on the vps) to your VPS machine.

    Dave

  • Matt 158 posts 389 karma points
    6 days ago
    Matt
    0

    Hello Dave,

    I changed Modelsbuilder mode to Dll and generated the models but still no joy, I'll try make contact with with my VPS provider and see if its an issue with security.

    Although my host EUKhost was recommended by this forum by a few people so I would hope that it shouldn't have any issues

  • Matt 158 posts 389 karma points
    6 days ago
    Matt
    0

    Hello Dave,

    I made those changes but still no joy.

    They are saying that the VPS is setup correctly.

    Do you have any other suggestions?

    Thanks

  • Dave Woestenborghs 3159 posts 10354 karma points MVP 3x admin c-trib
    5 days ago
    Dave Woestenborghs
    0

    Hi Matt,

    Can you maybe post some code of your template ?

    Dave

  • Matt 158 posts 389 karma points
    5 days ago
    Matt
    0

    Hello Dave,

    @{
         var homeNode = Model.Content.Site().OfType<Home>();
        @Html.Partial("ExampleNavigation", homeNode.MainNavigation)
    }
    

    This is my parctial view, if I remove it from my master template the website will load fine (Although then I wont have a navigation)

    And here is my navigation partial

    @using Cogworks.Meganav.Models
    @model IEnumerable<MeganavItem>
    
        <div data-collapse="medium" data-animation="default" data-duration="400" class="navbar w-nav">
        <div class="w-container">
            <a href="#" class="brand w-nav-brand">
                    <h2 class="logo">Salt &amp; Pepper</h2>
                    <h3 class="logo2">Vintage</h3>
                </a>
        <nav role="navigation" class="nav-menu-mobile w-nav-menu">
    
          @foreach(var topLevelEntry in Model)
            {
             if(topLevelEntry.Children != null && topLevelEntry.Children.Any())
                {
        <div data-hover="1" data-delay="0" class="drop-down-menu w-dropdown">
        <div class="nav-link w-dropdown-toggle">
        <div>@topLevelEntry.Title</div>
        </div>
        <nav class="w-dropdown-list">
            @RenderChildren(topLevelEntry.Children)
        </nav>
        </div>
        }else{
        <a href="@topLevelEntry.Url" class="link w-nav-link">@topLevelEntry.Title</a>
                    }
            }
        </nav>
        <div class="menu-button w-nav-button">
        <div class="icon w-icon-nav-menu"></div>
                </div>
            </div>
    
            @helper RenderChildren(IEnumerable<MeganavItem> items)
    {
        if (items.Any())
        {
            foreach (var item in items)
            {        
                <a href="@item.Url" class="dropdown-link w-dropdown-link">@item.Title</a>
            }
        }
    }  
    
  • Matt 158 posts 389 karma points
    2 days ago
    Matt
    0

    Hello all,

    Any ideas? :)

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft