Skip to content

Commit ed9ad43

Browse files
committed
Put in place condition for PageLevelNavigation
Previously, if a page didn't include `PageLevelNavigation`, the partial view would fail due to an attempt to iterate a `null` object. This fixes that issue by wrapping that loop in a condition. This allows a far greater number of pages to be previewed in the local `Host` project. That said, when connecting to customer databases for testing, this will still fail to recognize any pages associated with proprietary content types, since those won't have local views associated with them.
1 parent 8590d46 commit ed9ad43

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • OnTopic.AspNetCore.Mvc.Host/Views/Shared/Components/PageLevelNavigation

OnTopic.AspNetCore.Mvc.Host/Views/Shared/Components/PageLevelNavigation/Default.cshtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
<h2>PageLevelNavigation</h2>
44
<ul>
5-
@foreach (var topic in Model.NavigationRoot.Children) {
6-
<li><a href="@topic.WebPath">@(topic.ShortTitle?? topic.Title)</a></li>
5+
@if (Model.NavigationRoot != null) {
6+
foreach (var topic in Model.NavigationRoot.Children) {
7+
<li><a href="@topic.WebPath">@(topic.ShortTitle?? topic.Title)</a></li>
8+
}
79
}
810
</ul>
911

0 commit comments

Comments
 (0)