asp.net core – asp-controller and asp-action attributes not working

asp.net core – asp-controller and asp-action attributes not working

After a little bit of digging I found that asp-controller and asp-action attributes are called anchor tag helpers, and are part of the

Microsoft.AspNetCore.Mvc.TagHelpers namespace

Apparently it is an alternative to using Razor. I was able to resolve the issue by creating _ViewImports.cshtml and adding the below into the file:

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Once done that, anchor tag helpers were recognized and button start working as anticipated.

When working with Areas I had to copy _ViewImport to the new AreaMyAreaViews

asp.net core – asp-controller and asp-action attributes not working

Adding @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers to the top of the cshtml file is worked.

Leave a Reply

Your email address will not be published.