Adding a Route Parameter

Learn how to pass value in route as parameter in Razor components.

We'll cover the following

Components can have multiple @page directives. We will add an @page directive to the Counter component that uses a parameter. We do this as follows:

  1. Return to Visual Studio.
  2. Open the Pages\Counter.razor file.
  3. Add the following @page directive to the top of the file:

Get hands-on with 1200+ tech skills courses.