liveBook · Manning

Parameter transformer

As explained in ASP.NET Core in Action, 3e

A parameter transformer is a routing component that transforms route parameter or token text when generating route templates or URLs.

A parameter transformer changes route parameter text while Razor Pages generates route templates or URLs. A common use is converting PascalCase names such as ProductDetails into kebab-case, such as product-details. section 14.6

Kebab-case transformation

Implement IOutboundParameterTransformer, return null for a null value, and use a regular expression to insert hyphens between lowercase and uppercase letters before lowercasing the result.

Register the transformer through AddRazorPagesOptions and PageRouteTransformerConvention to apply the convention across Razor Pages. RouteOptions separately handles lowercase URLs and trailing slashes.

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains the interface implementation and registration, but stops short of broader routing internals.
Examples
Uses PascalCase-to-kebab-case conversion and Razor Pages registration through PageRouteTransformerConvention.
What it assumes
Assumes basic C# and Razor Pages configuration while demonstrating the transformer implementation from its interface upward.
What you can do after
Build it from scratch as a C# IOutboundParameterTransformer and register it as a Razor Pages convention.
How it connects
Connects outbound parameter transformation with Razor Pages conventions, RouteOptions, and route templates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.