I'm trying to use ASP.NET 5 Tag Helpers. Having configured server-side error messages, I'm receiving the following:
error CS0103: The name 'addtaghelper' does not exist in the current context
From reading online tutorials, addtaghelper
is supposed to exist. In project.json
we've added this:
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta4"
Also, in _ViewStart.cs
we have the following:
@addtaghelper "Microsoft.AspNet.Mvc.TagHelpers"
Why does addtaghelper
not exist in the current context? How can we add it to the current context?
I've tried camel casing as @addTagHelper
but this leads to a new error:
Invalid tag helper directive look up text 'Microsoft.AspNet.Mvc.TagHelpers'. The correct look up text format is: "typeName, assemblyName".
The answer is in the source on GitHub. This is the directive to add.
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
Gotchas:
*
for the typeName
.project.json
must have "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta4"
in the dependencies
section.See also: https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro#managing-tag-helper-scope