I am using razor pages and.net 5.0
My page name is Edit.cshtml
which has page directive url as
@page /p/{id}
Now from another page I want to generate put a anchor tag to this page
I know we can just do it by
<a href="/p/id">
but I want to generate it with anchor tage helper in .net lik asp-page, asp-route
beacuse here my page name and route is different I can't generate.
Is there any other way to generate it?
CodePudding user response:
It doesn't matter, if your page directive differs from your page name.
If your page is called "Edit" with a route /p/{id}
create a tag helper like this:
<a asp-page="/Edit" asp-route-id="3">Click here to edit things.</a>
This will generate the following markup
<a href="/p/3">Click here to edit things.</a>