Live Chat Icon For mobile
Live Chat Icon

How do you handle the parameter in routing in Blazor?

Platform: Blazor| Category: Routing

The parameters can be defined using curly braces within a routing template in both the @page directive and RouteAttribute.

Using @page directive

@page "/Route"
@page "/Route/{id}"

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

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

Using RouteAttribue

[Route("/Route/{id}")]
public class BaseComponent: ComponentBase
{
    public string Id { get; set; }
}

Reference link:

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

https://www.c-sharpcorner.com/article/routing-in-blazor/

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

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

Please submit your question and answer.