Hi All,
New to Umbraco, Just about 10 hours in and learning, Bare with me if anything is "noobish".
I have a master page, child template setup and running into issues with some inheritance etc.
Master Template has:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using ContentModels = Umbraco.Web.PublishedContentModels;
@using Umbraco.Core
@{
Layout = null;
}
I am calling a partial:
@Html.CachedPartial("Header", Model.Content, 3600, true)
This renders. In this partial I have:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using ContentModels = Umbraco.Web.PublishedContentModels;
@using Umbraco.Core
I have a layout and for a navigation I call a Navigation Partial:
@Html.Partial("~/Views/Partials/Navigation/TopNavigation.cshtml")
I am using this megaNav:
https://github.com/thecogworks/meganav
And its code they provide the basic loop through and here is where I have my current issue.
At the top of this partial I have:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using Umbraco.Web;
@using Umbraco.Web.Models;
@using Cogworks.Meganav.Models;
And the for loop:
@foreach (var item in Model.Content.GetPropertyValue<IEnumerable<MeganavItem>>("navigation"))
When I am on my homepage document type
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = "Master.cshtml";
}
The navigation renders fine.
But when I am on a page using the page document type the site produces an error.
![enter image description here]()
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.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 8: <div class="nav navv2">
Line 9: <ul>
Line 10: @foreach (var item in Model.Content.GetPropertyValue<IEnumerable<MeganavItem>>("navigation"))
Line 11: {
Line 12: if (item.Children.Any()){
This line:
@foreach (var item in Model.Content.GetPropertyValue<>
Can anyone help me with the issue please?