An anchor element creates a hyperlink and is the basic mechanism for navigating through an application with HTTP GET requests. In ASP.NET Core, AnchorTagHelper transforms its href using the routing system, avoiding hard-coded URLs and reflecting routing changes automatically. section 26.3
Configure the destination with tag-helper attributes:
- Use asp-action and asp-controller to target a controller action. section 26.3
- Supply route-segment values with asp-route-[name], such as asp-route-id. section 26.3
- Use asp-page for a Razor Page and asp-page-handler for its handler method. section 26.3.1
- Add asp-fragment, asp-host, or asp-protocol when the generated URL needs those components. section 26.3
Linking a product row to an action
<a asp-action="index" asp-controller="home" asp-route-id="@Model?.ProductId" class="btn btn-sm btn-info text-white">Select</a> For product ID 3, rendering produces href="/Home/index/3". Clicking the anchor sends a GET request to the selected controller action with the route value available as its id argument. section 26.3
Linking to a Razor Page
<a asp-page="/suppliers/list" class="btn btn-secondary">Suppliers</a> The helper resolves the page route, including any route convention or @page override, instead of requiring the rendered path to be written manually. section 26.3.1



