Roadmap › 1. .NET › Step 20
MVC

ASP.NET Core MVC (and Razor Pages)

The MVC pattern, request lifecycle, routing, controllers, model binding and validation, Razor views, layouts, tag helpers, view components, filters, state management, Identity and security.
What it is & where it is used

ASP.NET Core MVC is a framework for building server-rendered web apps using the Model–View–Controller pattern on top of the ASP.NET Core pipeline.

  • Model — data and business rules (entities, view models, validation).
  • View — the UI, written in Razor (.cshtml — HTML + C#).
  • Controller — handles the request, calls services, picks a view or result.

The same framework also offers Razor Pages (page-focused: each .cshtml has a PageModel), Web API controllers (JSON, no views — next course) and Blazor (component-based UI in C#).

Interview focus areas: request lifecycle, routing, model binding/validation, filters, ViewData/ViewBag/TempData, partial views vs view components, tag helpers, authentication/authorisation, antiforgery.

Versions & history
VersionYearHighlights
ASP.NET MVC 1–52009–2013On .NET Framework / System.Web; MVC 5 + Web API 2 were separate frameworks
ASP.NET Core 1.02016Rewrite: cross-platform, Kestrel, built-in DI; MVC and Web API unified
ASP.NET Core 2.02017Razor Pages, Microsoft.AspNetCore.All metapackage
ASP.NET Core 2.1 / 2.22018[ApiController], HTTPS by default, GDPR features, SignalR, Identity UI as Razor Class Library
ASP.NET Core 3.0 / 3.12019Endpoint routing, Blazor Server, generic host, System.Text.Json
ASP.NET Core 5 / 62020 / 2021Minimal hosting model (WebApplication), Minimal APIs, hot reload
ASP.NET Core 72022Rate limiting, output caching middleware
ASP.NET Core 82023Blazor Web App (static SSR + interactivity), Identity API endpoints, keyed DI, AOT for minimal APIs
ASP.NET Core 92024MapStaticAssets (fingerprinted, compressed static files), built-in OpenAPI, HybridCache
ASP.NET Core 102025Ships with .NET 10 (LTS): validation for Minimal APIs, OpenAPI 3.1, passkey support in Identity, Blazor improvements
Lifecycle

MVC request lifecycle (in order):

  1. Request arrives at Kestrel (possibly via IIS/Nginx).
  2. Middleware pipeline runs in registration order: exception handler → HSTS/HTTPS redirection → static files → routing → CORS → authentication → authorization → session → endpoints.
  3. Endpoint routing matches the URL to a controller action (conventional or attribute routes).
  4. Controller creation — the controller factory creates the controller via DI.
  5. Filter pipeline begins: authorization filters → resource filters (before) → model binding → model validation → action filters (OnActionExecuting).
  6. Action method executes and returns an IActionResult (View(), RedirectToAction(), Json(), ...).
  7. Action filters (OnActionExecuted) → result filters (OnResultExecuting).
  8. Result execution — for ViewResult, the view engine finds the .cshtml, runs _ViewStart, layout, view, partials/view components, and writes HTML.
  9. Result filters (OnResultExecuted) → resource filters (after).
  10. Exception filters handle unhandled exceptions from controller/action stages.
  11. Response flows back out through middleware to the client.

Razor view lifecycle: _ViewImports.cshtml (usings, tag helpers) → _ViewStart.cshtml (sets Layout) → view body renders → @RenderBody() in the layout → @RenderSection("Scripts", required: false).

Tools used to develop
  • Visual Studio — MVC templates, scaffolding (controllers + views from a model), Razor IntelliSense, Browser Link, Hot Reload.
  • dotnet new mvc, dotnet new webapp (Razor Pages), dotnet aspnet-codegenerator (scaffolding CLI).
  • LibMan / npm — client libraries (Bootstrap, jQuery validation).
  • ASP.NET Core Identity + scaffolded Identity UI.
  • Browser DevTools, Fiddler, Postman — inspect requests.
  • Glimpse-style diagnostics: app.UseDeveloperExceptionPage() (default in Development), logging.