Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在aspcore中使用AnchorTagHelper_C#_Asp.net Core_Asp.net Core Mvc - Fatal编程技术网

C# 在aspcore中使用AnchorTagHelper

C# 在aspcore中使用AnchorTagHelper,c#,asp.net-core,asp.net-core-mvc,C#,Asp.net Core,Asp.net Core Mvc,我试图使用anchortag助手在aspcore中实现活动菜单,但在调试时它没有命中代码 这是我的密码 .cshtml <li> <a asp-area="Admin" is-active asp-controller="p1" asp-action="Index">P1</a> </li> <li> <a asp-area="Admin" i

我试图使用anchortag助手在aspcore中实现活动菜单,但在调试时它没有命中代码

这是我的密码

.cshtml

<li>
  <a asp-area="Admin" is-active asp-controller="p1" asp-action="Index">P1</a>
</li>
<li>
  <a asp-area="Admin" is-active asp-controller="p2" asp-action="Index">P2</a>
</li>
<li>
  <a asp-area="Admin" is-active asp-controller="p3" asp-action="Index">P3</a>
</li>
_ViewImports.cshtml

@using WebApp
@using Models
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
@addTagHelper "*, ActiveClassTagHelper"

我在ActiveClassTagHelper中使用断点,但它不起作用。任何建议都会有帮助。

示例中的以下行不正确:

这将尝试注册
ActiveClassTagHelper
程序集中存在的所有标记帮助程序(使用
*

这给您留下了两个选择:

  • 这将注册程序集中的所有标记帮助程序

  • 这仅注册程序集中的
    ActiveClassTagHelper
    标记帮助程序

  • 除非您想选择要包含哪些标记帮助程序,否则我建议您选择选项1

    @using WebApp
    @using Models
    @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
    @addTagHelper "*, ActiveClassTagHelper"
    
    @addTagHelper "*, ActiveClassTagHelper"
    
    @addTagHelper *, NameOfAssembly
    
    @addTagHelper FullNameSpace.ActiveClassTagHelper, NameOfAssembly