ASP.NET Core MVC (and Razor Pages)
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
| Version | Year | Highlights |
|---|---|---|
| ASP.NET MVC 1–5 | 2009–2013 | On .NET Framework / System.Web; MVC 5 + Web API 2 were separate frameworks |
| ASP.NET Core 1.0 | 2016 | Rewrite: cross-platform, Kestrel, built-in DI; MVC and Web API unified |
| ASP.NET Core 2.0 | 2017 | Razor Pages, Microsoft.AspNetCore.All metapackage |
| ASP.NET Core 2.1 / 2.2 | 2018 | [ApiController], HTTPS by default, GDPR features, SignalR, Identity UI as Razor Class Library |
| ASP.NET Core 3.0 / 3.1 | 2019 | Endpoint routing, Blazor Server, generic host, System.Text.Json |
| ASP.NET Core 5 / 6 | 2020 / 2021 | Minimal hosting model (WebApplication), Minimal APIs, hot reload |
| ASP.NET Core 7 | 2022 | Rate limiting, output caching middleware |
| ASP.NET Core 8 | 2023 | Blazor Web App (static SSR + interactivity), Identity API endpoints, keyed DI, AOT for minimal APIs |
| ASP.NET Core 9 | 2024 | MapStaticAssets (fingerprinted, compressed static files), built-in OpenAPI, HybridCache |
| ASP.NET Core 10 | 2025 | Ships with .NET 10 (LTS): validation for Minimal APIs, OpenAPI 3.1, passkey support in Identity, Blazor improvements |
Lifecycle
MVC request lifecycle (in order):
- Request arrives at Kestrel (possibly via IIS/Nginx).
- Middleware pipeline runs in registration order: exception handler → HSTS/HTTPS redirection → static files → routing → CORS → authentication → authorization → session → endpoints.
- Endpoint routing matches the URL to a controller action (conventional or attribute routes).
- Controller creation — the controller factory creates the controller via DI.
- Filter pipeline begins: authorization filters → resource filters (before) → model binding → model validation → action filters (OnActionExecuting).
- Action method executes and returns an
IActionResult(View(),RedirectToAction(),Json(), ...). - Action filters (OnActionExecuted) → result filters (OnResultExecuting).
- Result execution — for
ViewResult, the view engine finds the.cshtml, runs_ViewStart, layout, view, partials/view components, and writes HTML. - Result filters (OnResultExecuted) → resource filters (after).
- Exception filters handle unhandled exceptions from controller/action stages.
- 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.