What is ViewImports in ASP.NET Core MVC
Ranjit Kumar
Select an image from your device to upload
In ASP.NET Core MVC, the ViewImports file is used to globally import namespaces, tag helpers, and other configurations for Razor views. This eliminates the need to repeatedly include namespaces or directives in every Razor page or view file.
ViewImports
Example of ViewImport
@using MyApp.Models@using MyApp.Services@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers@addTagHelper *, MyApp
@using MyApp.Models
@using MyApp.Services
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, MyApp