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.

PartResponsibilityExample
ModelData and business rules (entities, view models, validation)Product, ProductViewModel
ViewPresentation — Razor templates producing HTMLViews/Products/Index.cshtml
ControllerHandles the request, calls services, chooses the view/resultProductsController.Index()
Web FormsMVC 5ASP.NET Core MVC
ModelEvent-driven pages, ViewStateRequest → controller action → viewSame as MVC 5, rebuilt
HTML controlGenerated by controlsFullFull
TestabilityPoorGoodVery good (built-in DI)
Platform.NET Framework, IIS.NET Framework, IIS (System.Web)Cross-platform, Kestrel
DIThird-partyThird-party (Unity, Autofac, Ninject)Built in
Versions & history
VersionYearHighlights
MVC 1.02009Controllers, ASPX view engine, routing, HTML helpers
MVC 22010Areas, strongly typed helpers (TextBoxFor), data annotations validation, async controllers
MVC 32011Razor view engine, unobtrusive JavaScript validation, global filters, ViewBag, NuGet
MVC 42012Web API, mobile templates, async/await controllers (Task<ActionResult>), bundling & minification
MVC 52013Attribute routing, ASP.NET Identity, authentication filters, filter overrides, Bootstrap templates, One ASP.NET
MVC 5.1 / 5.22014Enum 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 browser
Tools 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.