My question is pretty simple: how can I specify a parameter inside my URL, for example, if the URL is
https://localhost:5001/passParameter/thisIsAString
and I have the code
@code {
<p>@(urlParameter)</p>
[Parameter] public string urlParameter { get; set; }
}
then the page will say "thisIsAString"? I searched everywhere but found no solution. Thanks for the help!
CodePudding user response:
You can specify the route parameter in the @page
directive and it will be assigned to the property in the component of the same name:
@page "/passParameter/{urlParameter}"
<p>@(urlParameter)</p>
@code {
[Parameter] public string urlParameter { get; set; }
}
See Route parameters for more details.