ASP.NET Core MVC Interview Question #176

How would you structure a production ASP.NET Core MVC application?

Senior Practical MVC Scenarios & Production Architecture Senior Advanced

Quick Interview Answer

A production MVC application should separate HTTP concerns from application and business logic. Controllers handle requests and responses, ViewModels define UI contracts, application services coordinate use cases, and infrastructure components handle persistence and external systems.

Detailed Explanation

A production MVC application should separate HTTP concerns from application and business logic. Controllers handle requests and responses, ViewModels define UI contracts, application services coordinate use cases, and infrastructure components handle persistence and external systems.

The exact number of projects or layers should match the application's complexity. The goal is clear dependency boundaries and maintainability, not adding layers for their own sake.

Code Example

// Typical responsibilities:
// Web: Controllers, Views, ViewModels
// Application: Use cases / services
// Domain: Business rules
// Infrastructure: EF Core, email, external APIs

builder.Services.AddScoped<IProductService, ProductService>();
builder.Services.AddDbContext<AppDbContext>();