Search code examples
razorasp.net-core-mvctag-helpersasp.net-core-tag-helpers

ASP.NET Core Tag Helpers in centralized place


I am using the asp.net core tag helpers and I've to put the following two lines at the beginning of any view file to be able to use the tag helpers in that file

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

Is there a way I can put them in a centralized place (for example _Layout.cshtml) and I can use the tag helpers at any view file?


Solution

  • You can put all using directives and information about used tag helpers into _ViewImports.cshtml file.

    More information about is in documentation