Reputation: 476
I have a link in Index page with the Id is string:
<a href="/usr/view/@Item.Id">Edit</a>
When this link is clicked, it suppose to open View page, but it didn't. This is the View page:
@page "/usr/view/{id:int}"
<h3>View</h3>
@code {
[Parameter] public int id { get; set; }
}
I tried to change the {id:int} to {id:string} but this error came out:
Unsupported constraint 'string' in route '/usr/view/{id:string}'.
How do I go about this? My Id must be a string.
Upvotes: 0
Views: 948
Reputation: 7186
How about just @page "/usr/view/{id}"
? You might also want to use asp-page
and asp-route-id
in the anchor tag, so that you can change the URL without having to change the HTML link.
string
is the default if no constraint is provided.
Upvotes: 1