Roadmap › 1. .NET › Step 18
MVC5
ASP.NET MVC 5 (.NET Framework) — Folder Structure, Request Life Cycle and Features
The MVC pattern, the classic MVC 5 project and folder structure (App_Start, Controllers, Models, Views, Areas, Global.asax, Views/web.config), the full request life cycle from UrlRoutingModule to MvcHandler, controller factory, action invoker, filters, model binding, action results and the Razor view engine, routing (convention and attribute), controllers and action results, Razor views, HTML helpers, partial views and child actions, model binding and validation, filters (authorization, action, result, exception), ViewBag/ViewData/TempData, bundling, dependency injection with Unity/Autofac, OWIN and ASP.NET Identity, Web API 2 side by side, error handling and migrating MVC 5 to ASP.NET Core.
What it is & where it is used
ASP.NET MVC (2009) brought the Model–View–Controller pattern to ASP.NET on .NET Framework as an alternative to Web Forms: no ViewState, no page life cycle, full control of HTML, clean URLs and testable controllers. MVC 5 (2013) is the final version; its successor is ASP.NET Core MVC.
| Part | Responsibility | Example |
|---|---|---|
| Model | Data and business rules (entities, view models, validation) | Product, ProductViewModel |
| View | Presentation — Razor templates producing HTML | Views/Products/Index.cshtml |
| Controller | Handles the request, calls services, chooses the view/result | ProductsController.Index() |
| Web Forms | MVC 5 | ASP.NET Core MVC | |
|---|---|---|---|
| Model | Event-driven pages, ViewState | Request → controller action → view | Same as MVC 5, rebuilt |
| HTML control | Generated by controls | Full | Full |
| Testability | Poor | Good | Very good (built-in DI) |
| Platform | .NET Framework, IIS | .NET Framework, IIS (System.Web) | Cross-platform, Kestrel |
| DI | Third-party | Third-party (Unity, Autofac, Ninject) | Built in |
Versions & history
| Version | Year | Highlights |
|---|---|---|
| MVC 1.0 | 2009 | Controllers, ASPX view engine, routing, HTML helpers |
| MVC 2 | 2010 | Areas, strongly typed helpers (TextBoxFor), data annotations validation, async controllers |
| MVC 3 | 2011 | Razor view engine, unobtrusive JavaScript validation, global filters, ViewBag, NuGet |
| MVC 4 | 2012 | Web API, mobile templates, async/await controllers (Task<ActionResult>), bundling & minification |
| MVC 5 | 2013 | Attribute routing, ASP.NET Identity, authentication filters, filter overrides, Bootstrap templates, One ASP.NET |
| MVC 5.1 / 5.2 | 2014 | Enum helpers, attribute routing constraints, bug fixes; 5.2.x maintenance releases (latest 5.3.0 in 2023) |
Lifecycle
The MVC 5 request life cycle (inside IIS + System.Web):
text
1. Browser → IIS → ASP.NET pipeline (HttpApplication events, Global.asax)
2. UrlRoutingModule (PostResolveRequestCache) matches the URL against RouteTable.Routes
3. Matched route → MvcRouteHandler → creates MvcHandler (an IHttpHandler)
4. MvcHandler.ProcessRequest → ControllerBuilder → IControllerFactory (DefaultControllerFactory or your DI factory)
creates the controller, e.g. ProductsController
5. Controller.Execute → ControllerActionInvoker:
a. finds the action method (name + HTTP verb + selectors)
b. Authentication filters → Authorization filters ([Authorize])
c. Model binding: route values, query string, form → action parameters; validation → ModelState
d. Action filters OnActionExecuting → ACTION METHOD runs → OnActionExecuted
e. Action returns an ActionResult (ViewResult, JsonResult, RedirectResult …)
f. Result filters OnResultExecuting → ActionResult.ExecuteResult → OnResultExecuted
6. ViewResult → ViewEngines (RazorViewEngine) locate the .cshtml → compiled into a class → rendered with layout/partials → HTML
7. Exception filters handle errors at any step ([HandleError]) → Application_Error as last resort
8. Response flows back through the remaining pipeline events (EndRequest) to the browserTools used to develop
- Visual Studio with "ASP.NET Web Application (.NET Framework)" → MVC template; scaffolding (Add → Controller with views, using Entity Framework).
- IIS / IIS Express; Glimpse (legacy request inspector); MiniProfiler; ELMAH for errors.
- NuGet packages:
Microsoft.AspNet.Mvc,Microsoft.AspNet.Razor,Microsoft.AspNet.Web.Optimization(bundling),Microsoft.AspNet.Identity.*,Unity.Mvc5/Autofac.Mvc5. - Migration: .NET Upgrade Assistant, System.Web adapters, YARP for side-by-side migration.