Reputation: 51
I am trying to use View Components using tag helpers in a Razor page in a new ASP.NET Core 3.1 project.
Invoking as follows works:
@await Component.InvokeAsync("LeftSidebar")
Using the tag helper however doesn't and what's more Visual Studio does not seem to recognise the "vc" tag at all:
<vc:left-sidebar></vc:left-sidebar>
I have added the "addTagHelpers" to the _ViewImports.html file but it's not picking it up. I also read somewhere it requires a model so tried doing that with no joy.
Anyone else had this? Literally have wasted hours and will go back to the non-tag helper syntax for now.
Upvotes: 0
Views: 1229
Reputation: 51
My mistake was including a ";" at the end of the add tag helper in the _ViewImports file. Fixing this, cleaning the project and rebuilding everything sprung to life.
Upvotes: 3