How do you define route parameters and apply route constraints in a Blazor component?

Last updated 5 July 2026

  • Route parameters are {name} placeholders in @page, bound case-insensitively to a matching [Parameter] property.

  • Constraints add a type after a colon (e.g. {id:int}, also bool, guid, datetime, long). Non-matching values simply don't match the route.

  • Make parameters optional with ? (e.g. {id:int?}) or multiple @page directives, binding to nullable types.

  • https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-10.0
  • https://www.youtube.com/watch?v=wYX1m8ofnLQ
  • https://blazor-university.com/routing/route-parameters/
  • https://blazor-university.com/routing/constraining-route-parameters/
  • https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-10.0
  • https://www.telerik.com/blogs/blazor-basics-blazor-routing-navigation-fundamentals
  • https://www.telerik.com/blogs/blazor-basics-child-routes-optional-route-parameters
  • https://darthpedro.net/2021/03/29/how-to-define-routing-parameters-on-blazor-page/
All Blazor interview questions