liveBook · Manning

Asp-area attribute

As explained in ASP.NET Core in Action, 3e

The asp-area attribute is an ASP.NET Core Tag Helper attribute that specifies the area associated with a generated link.

The asp-area attribute assigns an area route value to a link generated by an ASP.NET Core Tag Helper. For Razor Pages in the Identity area, set it to Identity. section 23.3.2

Link to the Identity login page

Use the area together with asp-page to generate a link to the /Account/Login Razor Page: <a asp-area="Identity" asp-page="/Account/Login">Login</a>. section 23.3.2

<a asp-area="Identity" asp-page="/Account/Login">Login</a>

Inspect the complete Login link and see how asp-area combines with asp-page. section 23.3.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines the attribute and demonstrates one login-link example without detailing Tag Helper implementation internals.
Examples
Uses a Login link targeting the Identity area's /Account/Login Razor Page.
What you can do after
Apply it via ASP.NET Core Tag Helpers to generate links for Razor Pages in an area.
How it connects
Connects Tag Helpers, Razor Pages, areas, routing, and ASP.NET Core Identity.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.