Inside ASP.NET MVC Framework

Inside ASP.NET MVC Framework

Presented on KievAltNet, Network Conference 2011

This a speech dedicated to experienced ASP.NET MVC developers who is curious about - "How things are done?". During the talk we'll make a trip right from HttpRequest back to View rendering and response produce.

F32f547e66f3b6528376d67fdb67008f?s=128

Alexander Beletsky

October 30, 2011
Tweet

Transcript

  1. 3.

    Hey, it's open source • See what happens behind the

    curtain • Improve your knowledge • Learn from best • Super fun
  2. 5.

    ASP.NET is foundation • Request processing engine • Pushing request

    thought pipeline • Pipeline consists of Modules • And ends with Handler
  3. 6.

    MvcHanlder - heart of ASP.NET MVC • Implements IHttpAsyncHandler, IHttpHandler

    • Creates the ControllerFactory • Execute the controller
  4. 9.

    Here comes Routing • Included in framework 3.5 SP1 •

    Implements recomendations by Jakob Nielsen • Save us of URL re-writing module • Provides decoupling of URL and page
  5. 13.

    Difference in MVC2 and MVC3 • MVC2 ControllerBuilder creates factory

    "directly" • MVC3 ControllerBuilder uses SingleServiceResolver • SingleServiceResolver depends on IDependencyResolver
  6. 15.

    IDependencyResolver • Bridge between ASP.NET MVC and IoC container •

    Very simple interface • Introduce extensibility for many entities
  7. 17.

    Controller Execution • Get the name of the Action from

    Route • Call ControllerActionInvoker to Invoke action
  8. 18.

    Filters • Authorization filters – Implements the IAuthorizationFilter attribute. •

    Action filters – Implements the IActionFilter attribute. • Result filters – Implements the IResultFilter attribute. • Exception filters – Implements the IExceptionFilter attribute.
  9. 19.

    Why use filters? • DRY code • AOP principles in

    action • Better reuse • Clean code • MVC3 introduces global filters
  10. 21.

    Action Results • ViewResult - Represents HTML and markup. •

    EmptyResult - Represents no result. • RedirectResult - Represents a redirection to a new URL. • JsonResult - Represents a JavaScript Object Notation result that can be used in an AJAX application. • JavaScriptResult - Represents a JavaScript script. • ContentResult - Represents a text result. • FileContentResult - Represents a downloadable file (with the binary content). • FilePathResult - Represents a downloadable file (with a path). • FileStreamResult - Represents a downloadable file (with a file stream).
  11. 22.

    Action Result rendering • Extract view name from Route •

    Find view associated with with Route & Action Result • Render the view