Inside asp.net mvc framework

457 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
457
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Inside asp.net mvc framework

  1. 1. Inside ASP.NET MVC framework Alexander Beletsky, E-conomic http://beletsky.net @alexbeletsky
  2. 2. ASP.NET MVC is cool! Why?
  3. 3. Hey, it's open source <ul><ul><li>See what happens behind the curtain </li></ul></ul><ul><ul><li>Improve your knowledge </li></ul></ul><ul><ul><li>Learn from best </li></ul></ul><ul><ul><li>Super fun </li></ul></ul>
  4. 4. ASP.NET or ASP.NET MVC  ? <ul><li>Have you heard such question? </li></ul>
  5. 5. ASP.NET is foundation <ul><ul><li>Request processing engine </li></ul></ul><ul><ul><li>Pushing request thought pipeline </li></ul></ul><ul><ul><li>Pipeline consists of Modules </li></ul></ul><ul><ul><li>And ends with Handler </li></ul></ul>
  6. 6. MvcHanlder - heart of ASP.NET MVC <ul><ul><li>Implements IHttpAsyncHandler, IHttpHandler </li></ul></ul><ul><ul><li>Creates the ControllerFactory </li></ul></ul><ul><ul><li>Execute the controller </li></ul></ul>
  7. 7. Show me the code
  8. 8. <ul><li>Who is responsible for calling MvcHander? </li></ul>
  9. 9. Here comes Routing <ul><ul><li>Included in framework 3.5 SP1 </li></ul></ul><ul><ul><li>Implements recomendations by Jakob Nielsen </li></ul></ul><ul><ul><li>Save us of URL re-writing module </li></ul></ul><ul><ul><li>Provides decoupling of URL and page </li></ul></ul>
  10. 10. <ul><li>Route = URL + Constraints + IRouteHanlder </li></ul>
  11. 11. Show me the code
  12. 12. ControllerBuilder & ControllerFactory <ul><ul><li>ControllerBuilder creates ControllerFactory </li></ul></ul><ul><ul><li>ControllerFactory creates Controller </li></ul></ul>
  13. 13. Difference in MVC2  and MVC3 <ul><ul><li>MVC2 ControllerBuilder creates factory &quot;directly&quot; </li></ul></ul><ul><ul><li>MVC3 ControllerBuilder uses SingleServiceResolver </li></ul></ul><ul><ul><li>SingleServiceResolver depends on IDependencyResolver </li></ul></ul>
  14. 14. Show me the code
  15. 15. IDependencyResolver <ul><ul><li>Bridge between ASP.NET MVC and IoC container </li></ul></ul><ul><ul><li>Very simple interface </li></ul></ul><ul><ul><li>Introduce extensibility for many entities </li></ul></ul>
  16. 16. Show me the code
  17. 17. Controller Execution <ul><ul><li>Get the name of the Action from Route </li></ul></ul><ul><ul><li>Call ControllerActionInvoker to Invoke action </li></ul></ul>
  18. 18. Filters <ul><ul><li>Authorization filters – Implements the IAuthorizationFilter attribute. </li></ul></ul><ul><ul><li>Action filters – Implements the IActionFilter attribute. </li></ul></ul><ul><ul><li>Result filters – Implements the IResultFilter attribute. </li></ul></ul><ul><ul><li>Exception filters – Implements the IExceptionFilter attribute. </li></ul></ul>
  19. 19. Why use filters? <ul><ul><li>DRY code </li></ul></ul><ul><ul><li>AOP principles in action </li></ul></ul><ul><ul><li>Better reuse </li></ul></ul><ul><ul><li>Clean code </li></ul></ul><ul><ul><li>MVC3 introduces global filters </li></ul></ul>
  20. 20. Show me the code
  21. 21. Action Results <ul><ul><li>ViewResult - Represents HTML and markup. </li></ul></ul><ul><ul><li>EmptyResult - Represents no result. </li></ul></ul><ul><ul><li>RedirectResult - Represents a redirection to a new URL. </li></ul></ul><ul><ul><li>JsonResult - Represents a JavaScript Object Notation result that can be used in an AJAX application. </li></ul></ul><ul><ul><li>JavaScriptResult - Represents a JavaScript script. </li></ul></ul><ul><ul><li>ContentResult - Represents a text result. </li></ul></ul><ul><ul><li>FileContentResult - Represents a downloadable file (with the binary content). </li></ul></ul><ul><ul><li>FilePathResult - Represents a downloadable file (with a path). </li></ul></ul><ul><ul><li>FileStreamResult - Represents a downloadable file (with a file stream). </li></ul></ul>
  22. 22. Action Result rendering <ul><ul><li>Extract view name from Route </li></ul></ul><ul><ul><li>Find view associated with with Route & Action Result </li></ul></ul><ul><ul><li>Render the view </li></ul></ul>
  23. 23. THANK YOU! http://www.beletsky.net/search/label/InsideMVC twitter: @alexbeletsky

×