Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 1.21 KB

composition-over-controllers.md

File metadata and controls

18 lines (14 loc) · 1.21 KB

Composition over controllers

ServiceComposer can be used to enhance a MVC web application by adding composition support to Controllers. ServiceComposer can be configured to use a technique called "Composition over controllers":

services.AddViewModelComposition(options =>
{
    options.EnableCompositionOverControllers();
});

snippet source | anchor

Once composition over controllers is enabled, ServiceComposer will inject a MVC filter to intercept all controllers invocations. If a route matches a regular controller and a set of composition handlers ServiceComposer will invoke the matching handlers after the controller and before the view is rendered.

Composition over controllers can be used as a templating engine leveraging the excellent Razor engine. Optionally, it can be used to add ViewModel Composition support to MVC web application without introducing a separate composition gateway.