Getting ready

A route constraint is inserted with an inline syntax, called inline constraints, in the following form: {parameter:constraint}.

There are several ways to create a route constraint:

  • Inserting a constraint when creating a route conventionally
  • Inserting a constraint when creating an attribute routing
  • Creating a class that implements IRouteConstraint

Get ASP.NET Core MVC 2.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.