简体   繁体   中英

ASP.NET Core use Tag Helpers in Component View

I'm developing a ASP.NET Core application (Visual Studio 2017 - Windows 10). The name of the project is SportWinkel. In my Views folder, there is a _ViewImports.cshtml file with this content:

@using SportWinkel

@addTagHelper SportWinkel.Infrastructure.*, SportWinkel
@addTagHelper *, Microsoft.AspNetCoreMvc.TagHelpers

I'm now adding a Component View in Views/Shared/Components/MyViewComponent (Default.cshtml), but tag helpers are not rendered by Razor.Only if I add this line on top of Default.cshtml, tag helpers are rendered correctly:

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Very strange, because normally each view inside the Views folder imports _ViewImports.cshtml automatically...

请在您的_viewImports内部放入如下所述的错误。

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM