Using statement in Asp.Net Core Mvc

Опубликовано: 17 Февраль 2026
на канале: Aura Theme
313
3

In ASP.NET Core MVC, you can add using statements for all views in one place by adding them to the _ViewImports.cshtml file. This file is usually located in the Views folder. Any using statements in _ViewImports.cshtml will apply to all views in the application, so you don’t have to add them manually to each view page.

Here’s how you can do it:
Open the _ViewImports.cshtml file in the Views folder.
Add your @using statements there. For example:
@using MyNamespace.Models
@using MyNamespace.ViewModels

These @using statements will now be available in all .cshtml view pages, simplifying your code and keeping it consistent.

Download Full source code:
https://auratheme.gumroad.com/

Suggest what projects would you like to download next:
https://forms.gle/AjK7k17Vjmc86xdDA