You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
While the current design allows intercepting the creation of controllers (using the IControllerActivator abstraction), this is currently almost impossible with view components. Currently, the DefaultViewComponentInvoker is responsible of creating view components by calling directly into the IServiceProvider inside its private CreateComponent method. Although this method actually calls the existing Activate method on the IViewComponentActivator abstraction, this abstraction actually expects a created instance; it is not responsible of creating instances, while it should be.
Because of this, intercepting the creation of view components basically means either creating a complete copy of the DefaultViewComponentInvoker class, or replacing the IServiceProvider with your own. Creating your own copy of DefaultViewComponentInvoker is obviously awful, and replacing the default IServiceProvder forces a user to replace the complete DI pipeline with its own container, but this isn't always possible, either because the user applies Pure DI (DI without container) or uses a DI library that is incompatible with the DI abstractions given by the new ASP.NET framework.
Intercepting the creation of view component classes however is very important, because -as the documentation states- view components are "mini-controller" that will almost always require dependencies of their own.
The addition of this extra 'view components' concept doesn't seem very useful, since we've always been able to do the same with controllers in MVC 5. Since the docs describe them as "mini-controllers", it would be more useful to merge those concepts back together again; this also removes the problem, because controllers already have abstractions that allow intercepting their creation.
Either an IViewComponentActivator abstraction should be changed so that it is responsible for creation of components as well (or it should delegate to another abstraction that is responsible of creating it), or the concepts of controllers and view components should be merged together.