How do you implement the routing constraints in Blazor?

Platform: Blazor| Category: Routing

A route constraint enforces type matching on a route segment to a component.

In the following example, the route to the Users component only matches if:

  • An Id route segment is present on the request URL.
  • The Id segment is an integer (int).
@page "/Route"
@page "/Route/{id:int}"

<h3>Routing Id: @Id</h3>

@code {
    [Parameter]
    public int Id { get; set; }
}

Reference link:

https://docs.microsoft.com/en-us/aspnet/core/blazor/routing?view=aspnetcore-3.1

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.