1
votes

I'm new to ASP.NET core. I follow the guide from MS (https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-2.2)

This is my helper:

using Microsoft.AspNetCore.Razor.TagHelpers;

namespace DemoApp.TagHelpers
{
    class TestTagHelper : TagHelper
    {
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName="div";
            output.Content.Append("Run...");
        }
    }
}

Added @addTagHelper *, DemoApp to _ViewImports.cshtml and added <test>Test</test> to my view.

But nothing happen...no tag replacing, no break point trigger...

Any ideas?

1
What is the actual name of your project? Is it just DemoApp? - Chris Pratt
Yes, DemoApp.csproj only - Joe Simth

1 Answers

2
votes

Finally, I found the problem. The helper class have to set to public.

namespace DemoApp.Helpers
{
    public class TestTagHelper : TagHelper
    {
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName="div";
            output.Content.Append("Run...");
        }
    }
}