I have a partial, which is a table. I want it in a partial because I want to use it, and its functionality, in more than one place, and inside other pages.
From what I can see, there’s no way to have some sort of controller dedicated to this partial, nor a shared controller. Therefore, all of the functions to populate the models for the table in the partial seemingly can’t be associated with the partial. They need to be duplicated in the PageModel of every page that has the partial.
What would be the best/proper way to achieve what I am asking?
>Solution :
If you want to create a reusable self-contained piece of UI that depends on data or needs its own controller, use a ViewComponent instead of a partial.
These components support DI so you can inject services into them to e.g. obtain data, and they accept parameters too.