ASP.NET Core MVC Interview Question #81

What is a route parameter transformer?

Advanced Routing, Filters, Areas & Application Structure Mid-Level Intermediate

Quick Interview Answer

A route parameter transformer can change how route values are represented during URL generation. A common example is converting PascalCase controller or action names into kebab-case URLs.

Detailed Explanation

A route parameter transformer can change how route values are represented during URL generation. A common example is converting PascalCase controller or action names into kebab-case URLs.

Parameter transformers are useful when an application wants consistent URL conventions without manually writing every route. They should be applied consistently so inbound and outbound routing behavior remains understandable.

Code Example

public sealed class SlugifyParameterTransformer
    : IOutboundParameterTransformer
{
    public string? TransformOutbound(object? value)
    {
        return value?.ToString()?.ToLowerInvariant();
    }
}