3. Project Structure
A new ASP.NET Core MVC project has a standard folder layout. Following it means any MVC developer can find things quickly. Create one with the command dotnet new mvc -n MyApp, then run it with dotnet run.
Key points
- Controllers: classes that handle requests.
- Models: classes for data and view models.
- Views: Razor pages, grouped in one folder per controller, plus Views/Shared for layouts and partials.
- wwwroot: static files such as CSS, JavaScript and images.
- Program.cs: starts the app, registers services and sets up routing.
- appsettings.json: configuration such as connection strings.
Example: Typical folder layout
MyApp/
Controllers/
HomeController.cs
Models/
Student.cs
Views/
Home/
Index.cshtml
Shared/
_Layout.cshtml
wwwroot/
css/site.css
Program.cs
appsettings.json
Show explanation
The folder name under Views must match the controller name without the word Controller. HomeController looks for views in Views/Home.