GoldSim / Website

Source code for the GoldSim.com website
https://www.goldsim.com/
3 stars 1 forks source link

Create Navigation View Components #9

Closed JeremyCaney closed 4 years ago

JeremyCaney commented 4 years ago

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:

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: