Files
Musify/backend/.agents/skills/aspnet-core/references/ui-mvc.md
T
Admin 3b98a05c3b chore(backend): install AI agent skills for the .NET stack
Run autoskills in backend/: detects .NET/C#/ASP.NET Core/Minimal API and
installs 13 skills for universal (.agents) and claude-code (.claude) agents,
with backend/skills-lock.json. Adds ASP.NET Core, Minimal API + OpenAPI,
file-upload and containerization skills on top of the prior C#/.NET set.
Removes the stale root skills from the old layout.
2026-07-05 03:48:31 +02:00

1.9 KiB

MVC

Primary docs:

Choose MVC When Actions And Views Matter

Prefer MVC when the application benefits from explicit controllers, action-based routing, filters, view models, and a strong separation between orchestration and presentation.

This is often the right fit for:

  • large server-rendered sites
  • applications with many cross-cutting filters or action conventions
  • applications that mix views and APIs in the same controller layer
  • teams already organized around controllers and views

Core Shape

Enable MVC with views using:

  • builder.Services.AddControllersWithViews();
  • app.MapControllerRoute(...)

Keep views focused on presentation. Keep controllers focused on HTTP orchestration. Put business rules in services.

Controller Guidance

  • Derive from Controller when the controller returns views
  • Keep actions small and explicit
  • Use model binding and validation instead of manual request parsing
  • Return view models, not EF entities, to views
  • Use POST-Redirect-GET for form submissions

View Guidance

  • Use layouts, partial views, and Tag Helpers to keep markup consistent
  • Keep complex display logic out of Razor markup when it becomes hard to follow
  • Use strongly typed view models
  • Avoid coupling views directly to persistence models

Structure And Scale

  • Use areas for large bounded sections such as Admin or BackOffice
  • Keep route conventions explicit
  • Apply filters when behavior truly belongs at the MVC layer
  • Avoid giant god controllers; split by cohesive feature or resource

Choosing MVC Over Razor Pages

Prefer MVC over Razor Pages when:

  • multiple related actions share controller-level behavior
  • handler-level authorization or action filters matter
  • URL and action design are more natural than page-file routing