Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ServiceComposer/ServiceComposer.AspNetCore/llms.txt

Use this file to discover all available pages before exploring further.

This guide covers two successive steps: the v2.0.0 → v2.1.0 minor update (which changed the write-support default) and the v2.x → v3.0.0 major update (which removed a large set of legacy types and APIs). Read both sections before upgrading, as several changes introduced as deprecations in v2 become hard removals in v3.

v2.0.0 → v2.1.0: Write support enabled by default

In v2.1.0, write support is enabled by default. If your application was explicitly calling EnableWriteSupport(), that call is now redundant (though harmless at this point). More importantly, if you need to restrict ServiceComposer to GET requests only, you must now explicitly disable write support:
public void ConfigureServices(IServiceCollection services)
{
    services.AddViewModelComposition(options => options.DisableWriteSupport());
}
When write support is disabled, ServiceComposer.AspNetCore will only respond to GET requests.

v2.x → v3.0.0

Version 3.0.0 finalises the migration to attribute-routing-based composition and removes all remaining legacy route-mapping helpers and v1-era types.
The following route mapping extension methods have been removed in v3.0.0 and will cause compile errors if still present in your codebase:
  • MapComposableRoute
  • MapComposableGet
  • MapComposablePost
  • MapComposableDelete
  • MapComposablePatch
  • MapComposablePut
Replace all usages with attribute-routing-based composition, MapCompositionHandlers, and MVC Endpoints.
The following types and members have been removed in v3.0.0:
  • EventHandler<TEvent>
  • IHandleRequests
  • IHandleRequestsErrors
  • IInterceptRoutes
  • IPublishCompositionEvents
  • ISubscribeToCompositionEvents
  • RegisterCompositionEventsSubscriber
  • RegisterRequestsHandler
  • HandleRequest
  • CompositionGateway
See the v1 → v2 upgrade guide for the replacement APIs introduced in v2.0.0. The CompositionGateway has been removed entirely; use the host integration and MVC Endpoints instead.
1

Replace legacy route mapping methods

Remove all calls to MapComposableRoute, MapComposableGet, MapComposablePost, MapComposableDelete, MapComposablePatch, and MapComposablePut. Switch to attribute routing on your composition handlers and register them via MapCompositionHandlers:
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
    app.UseRouting();
    app.UseEndpoints(builder => builder.MapCompositionHandlers());
}
2

Remove AddComposedRequestIdHeader and related helpers

AddComposedRequestIdHeader, GetComposedRequestId, and GetComposedRequestIdHeaderOr have been removed. Retrieve the request identifier through the composition context instead.First, obtain the composition context from the HttpRequest:
var context = request.GetCompositionContext();
Then read the RequestId property:
var requestId = context.RequestId;
3

Update IViewModelPreviewHandler.Preview calls

Two overloads of IViewModelPreviewHandler.Preview have been removed. Update any implementations or invocations to use the single remaining overload:
public class ViewModelPreviewHandler : IViewModelPreviewHandler
{
    public Task Preview(HttpRequest httpRequest)
    {
        return Task.CompletedTask;
    }
}
4

Remove EnableWriteSupport calls

The EnableWriteSupport() method has been removed in v3. Write support is on by default. Remove any call to EnableWriteSupport() from your ConfigureServices method. To disable write support, use DisableWriteSupport() as described in the v2.1.0 section above.
5

Replace vm.RaiseEvent with context.RaiseEvent

The dynamic vm.RaiseEvent() method has been removed. Raise events using the composition context obtained from the HttpRequest:
var context = request.GetCompositionContext();
await context.RaiseEvent(new AnEvent());

Build docs developers (and LLMs) love