liveBook · Manning

RouteOptions

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

RouteOptions is an ASP.NET Core options class that configures default rules for generated route URLs, including casing and trailing slashes.

RouteOptions configures default rules for URLs generated by ASP.NET Core routing. It can force lowercase paths, preserve or lowercase query strings, and append trailing slashes. Route matching remains case-insensitive, but generated links use one consistent format. section 6.4.3

Configure consistent generated URLs

Register RouteOptions with builder.Services.Configure<RouteOptions>(), then set LowercaseUrls and AppendTrailingSlash to true while leaving LowercaseQueryStrings false. Named endpoints such as healthcheck and product then receive these defaults when LinkGenerator.GetPathByName generates links. section 6.4.3

Use LinkOptions when one generated URL must differ from the application defaults. Its values override RouteOptions, which is useful when a legacy route requires different casing or slash behavior. section 6.5

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

How deep it goes
Explains configuration and per-link overrides, but defers the underlying configuration system to later treatment.
Examples
Uses named minimal API endpoints, lowercase paths, trailing slashes, unchanged query strings, and a legacy-route override.
What you can do after
Operate/configure generated links with application-wide defaults and targeted LinkOptions exceptions.
How it connects
Connects RouteOptions with LinkGenerator, LinkOptions, route templates, named endpoints, and URL generation.

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.