Share via

DynamicRouteValueTransformer Class


Provides an abstraction for dynamically manipulating route value to select a controller action or page.

public ref class DynamicRouteValueTransformer abstract
public abstract class DynamicRouteValueTransformer
type DynamicRouteValueTransformer = class
Public MustInherit Class DynamicRouteValueTransformer


DynamicRouteValueTransformer can be used with MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String) or MapDynamicPageRoute to implement custom logic that selects a controller action or page.

The route values returned from a TransformAsync(HttpContext, RouteValueDictionary) implementation will be used to select an action based on matching of the route values. All actions that match the route values will be considered as candidates, and may be further disambiguated by FilterAsync(HttpContext, RouteValueDictionary, IReadOnlyList<Endpoint>) as well as IEndpointSelectorPolicy implementations such as HttpMethodMatcherPolicy.

Operations on a DynamicRouteValueTransformer instance will be called for each dynamic endpoint in the following sequence:

Implementations that are registered with the service collection as transient may safely use class members to persist state across these operations.

Implementations DynamicRouteValueTransformer should be registered with the service collection as type DynamicRouteValueTransformer. Implementations can use any service lifetime. Implementations that make use of State must be registered as transient.





Gets or sets a state value. An arbitrary value passed to the transformer from where it was registered.


FilterAsync(HttpContext, RouteValueDictionary, IReadOnlyList<Endpoint>)

Filters the set of endpoints that were chosen as a result of lookup based on the route values returned by TransformAsync(HttpContext, RouteValueDictionary).

TransformAsync(HttpContext, RouteValueDictionary)

Creates a set of transformed route values that will be used to select an action.

Applies to