Подтвердить что ты не робот

Пользовательский помощник тега не работает

Я последовал за несколькими руководствами по созданию специального помощника тега для ASP Core.

Это мой помощник:

using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;

namespace ToolControlSystem.TagHelpers
{
    [HtmlTargetElement("description", Attributes = DescriptionAttributeName, TagStructure = TagStructure.NormalOrSelfClosing)]
    public class DescriptionTagHelper : TagHelper
    {
        private const string DescriptionAttributeName = "asp-for";


        [HtmlAttributeName(DescriptionAttributeName)]
        public ModelExpression Model { get; set; }

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            base.Process(context, output);

            var description = GetDescription(Model.ModelExplorer);

            output.TagName = "span";
            output.TagMode = TagMode.StartTagAndEndTag;
            output.Content.SetContent(description);
        }

        private string GetDescription(ModelExplorer modelExplorer)
        {
            string description;
            description = modelExplorer.Metadata.Placeholder;

            if (String.IsNullOrWhiteSpace(description))
            {
                description = modelExplorer.Metadata.Description;
            }

            return description;
        }
    }
}

Я _ViewImports.cshtml это в _ViewImports.cshtml: @addTagHelper *, ToolConstrolSystem.TagHelpers

Эннндд... ничего. Нет intellisense, без замены тега...

Есть идеи?

4b9b3361

Ответ 1

Вам нужно указать только имя сборки в файле импорта.

_ViewImports.cshtml: 

@addTagHelper *, ToolConstrolSystem

Ответ 2

См. Раздел "Управление тегами"

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, AuthoringTagHelpers

В приведенном выше коде используется синтаксис подстановки ("*"), чтобы указать, что все теги справки в указанной сборке (Microsoft.AspNetCore.Mvc.TagHelpers) будут доступны для каждого файла вида в каталоге представлений или подкаталоге.