In ASP.NET MVC Framework, the navigation elements were handled by their own controller—LayoutController—which is embedded using the @Html.Action() helper, thus allowing the logic and model of the layout to be separated from the TopicController and its models, views.
ASP.NET Core Approach
This approach is formalized in ASP.NET Core with the introduction of View Components, which achieves a similar approach by establishing a component format with their own controller-like backend code. And, unlike the @Html.Action() approach, this avoids issues with e.g. the ITopicRoutingService not being able to resolve a Topic for the request.
OnTopic Support
To support this, the updated version of OnTopic 5.8.0 includes the following out-of-the-box ViewComponents in the Ignia.Topics.AspNetCore.Mvc project:
MenuViewComponentBase<T>
NavigationTopicViewComponentBase<T>
PageLevelNavigationViewComponentBase<T>
These base classes provide much of the logic needed for implementation, thus simply requiring that implementors override them to specify GoldSim’s version of the INavigationTopicViewModel<T> class, and moving the views to the appropriate folder.
Implementation
Implementation requires the following steps:
[x] Override the Menu and PageLevelNavigation components to specify the GoldSim version of the INavigationTopicViewModel<T>
[x] Implement the CallsToActionViewComponent based on the NavigationTopicViewComponentBase<T>
[x] Implement the FooterViewComponent based on the NavigationTopicViewComponentBase<T>
[x] Move the views from /Views/Layout To /Views/Shared/Components/
In ASP.NET MVC Framework, the navigation elements were handled by their own controller—
LayoutController
—which is embedded using the@Html.Action()
helper, thus allowing the logic and model of the layout to be separated from theTopicController
and its models, views.ASP.NET Core Approach
This approach is formalized in ASP.NET Core with the introduction of View Components, which achieves a similar approach by establishing a component format with their own controller-like backend code. And, unlike the
@Html.Action()
approach, this avoids issues with e.g. theITopicRoutingService
not being able to resolve aTopic
for the request.OnTopic Support
To support this, the updated version of OnTopic 5.8.0 includes the following out-of-the-box
ViewComponent
s in theIgnia.Topics.AspNetCore.Mvc
project:MenuViewComponentBase<T>
NavigationTopicViewComponentBase<T>
PageLevelNavigationViewComponentBase<T>
These base classes provide much of the logic needed for implementation, thus simply requiring that implementors override them to specify GoldSim’s version of the
INavigationTopicViewModel<T>
class, and moving the views to the appropriate folder.Implementation
Implementation requires the following steps:
Menu
andPageLevelNavigation
components to specify the GoldSim version of theINavigationTopicViewModel<T>
CallsToActionViewComponent
based on theNavigationTopicViewComponentBase<T>
FooterViewComponent
based on theNavigationTopicViewComponentBase<T>
/Views/Layout
To/Views/Shared/Components/