So I was searching for a good way in ASP.Net Core to create some "controls" that render into a view. So far I found there are 3 options, and I wanted to get some feedback on them.
ViewComponents: These are like mini controllers and use methods like actions to render from a razor page (view). I believe they can have self-contained logic so there's no dependency on any parent view model.
EditorTemplate/DisplayTemplate folders: These exist under "Views/Shared/" and could be pulled into a view by passing a model property to them (using
@inject for ASP.Net Core: Allows injecting a type into a view (I have no idea if a partial view can be associated?).
I'm leaving out the ability to include partial views directly, as it is not my intent for the control system I'm porting over.
Tag Helpers - it's possible to inject the current view context and build controls from these also.
In an older ASP.NET MVC app I had some controls that rendered from the templates (#2). However for .Net Core, I'm contemplating on possibly using ViewComponents instead (which seem more powerful) for rendering associated razor views (the controls basically just wrap razor views). For the moment I'll be experimenting with converting to ViewComponents, but would love some advice on the matter, thanks.