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.
ICompositionContext is the central coordination object for a single composition request. It exposes the ability to raise events — which fan out to all interested subscribers and handlers — and a stable RequestId that identifies the in-flight composition. It is available to every handler, subscriber, and filter through the request.GetCompositionContext() extension method.
An experimental API (GetArguments) is also available on ICompositionContext. It allows handlers and subscribers to inspect the model-binding arguments that were bound to them by the framework, enabling richer runtime introspection without relying on reflection.
Namespace
ServiceComposer.AspNetCore
Interface definition
Obtaining the context
Call theGetCompositionContext() extension method on the current HttpRequest:
HttpRequestExtensions in the ServiceComposer.AspNetCore namespace.
Properties
RequestId
A unique identifier assigned to the current composition request. The same value is emitted in the
composed-request-id response header, making it easy to correlate log entries across multiple handlers that run in parallel.Methods
RaiseEvent<TEvent>
Raises an event and delivers it to everyICompositionEventsHandler<TEvent> and every ICompositionEventsSubscriber that has subscribed to TEvent on the current route.
The event instance to raise. The runtime type must match the type argument used in
ICompositionEventsHandler<TEvent> and publisher.Subscribe<TEvent>.Task — completes when all event handlers have finished processing.
GetArguments (ICompositionRequestsHandler) — Experimental SC0001
Returns the list of model-binding arguments that were bound to the specifiedICompositionRequestsHandler for the current request.
The handler instance whose bound arguments to retrieve. Pass
this when called from inside the handler.IList<ModelBindingArgument>? — the list of bound arguments, or null if no arguments were bound.
GetArguments (ICompositionEventsSubscriber) — Experimental SC0001
Returns the model-binding arguments bound to the specifiedICompositionEventsSubscriber.
The subscriber instance whose bound arguments to retrieve.
IList<ModelBindingArgument>?
GetArguments<T> (ICompositionEventsHandler) — Experimental SC0001
Returns the model-binding arguments bound to the specifiedICompositionEventsHandler<T>.
The event handler instance whose bound arguments to retrieve.
IList<ModelBindingArgument>?
ModelBindingArgument
ModelBindingArgument carries metadata about a single bound argument.
The name of the bound argument, matching the parameter or attribute name declared on the handler.
The bound value. May be
null if the source did not provide a value.The ASP.NET Core
BindingSource that provided the value (e.g. BindingSource.Route, BindingSource.Query, BindingSource.Body).ModelBindingArgumentExtensions
A set of extension methods onIList<ModelBindingArgument>? that simplify typed argument retrieval:
default(TArgument) when no matching argument exists.
Usage example
The example below shows a handler that raises an event and then uses the experimentalGetArguments API to access a route-bound product ID.
ProductRequested: