I'm using the .NET Core 2 "Razor Pages" format for a web app. It allows you to define how to map the URL to variable names with a simple directive at the top:
@page "{personId:int?}"
The above, for example, would map the URL /Person/Index/123
to the IndexModel.OnGetAsync(int personId)
function so that personId
would have a value of 123.
However, I've noticed that these values seem to be automatically added to any URL they could be, if a link exists on the page. If I add the following to the Index page:
<a asp-page="/Person/Details">Details</a>
…the actual HTML that's generated is:
<a href="/Person/Details/123">Details</a>
…meaning that because both the Index and Details pages have the same directive at the top, the value of personId
is implicitly passed between them.
Is there any way to prevent this, so that asp-page="/Person/Details"
would simply redirect to the Details page without any value passed for personId
?