If you are setting the href
itself directly, then you can just concat the things here:
<a href="https://www.itelde.com/flick?id=@Model" target="_blank">Flicker</a>
The asp-route-id
tag helper can be used when you are generating the href
by using asp-page
or asp-action
to refer to a Razor page or a controller action within your application. For example, if that Flicker
action is part of your app, you could write it like this:
<a asp-action="Flicker" asp-route-id="@Model" target="_blank">Flicker</a>
If you try to use asp-route-something
with an explicit href
, you should also get the following error at runtime:
InvalidOperationException: Cannot override the 'href' attribute for <a>. An <a> with a specified 'href' must not have attributes starting with 'asp-route-' or an 'asp-action', 'asp-controller', 'asp-area', 'asp-route', 'asp-protocol', 'asp-host', 'asp-fragment', 'asp-page' or 'asp-page-handler' attribute.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…