O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

ASP.NET MVC One Step Deeper

4.017 visualizações

Publicada em

This is a one step deeper into ASP.NET MVC, the presentation was originally part of Jordev web camp happened in Jordan on the 14th of May 2011.

The presentation is general and its target is to throw terms on the audience so they can have general understanding that they can use it later for more detailed study.

Publicada em: Tecnologia
  • Seja o primeiro a comentar

ASP.NET MVC One Step Deeper

  1. 1. ASP.NET MVC <br />One Step Deeper<br />
  2. 2. Who I am<br />Emad Alashi<br />Technical Team Leader in eSense software<br />http://www.EmadAshi.com<br />http://www.DotNetArabi.com<br />@EmadAshi<br />
  3. 3. DotNetArabi دوت نت عربي<br />
  4. 4. ASP.NET MVC <br />One Step Deeper<br />
  5. 5. ASP.NET MVC One Step Deeper<br /><ul><li>Fast intro
  6. 6. Dependency Injection
  7. 7. Action Filters
  8. 8. Razor
  9. 9. HTML Forms</li></li></ul><li>MVC Pattern<br />
  10. 10. ASP.NET MVC<br />
  11. 11. ASP.NET MVC<br />
  12. 12. Dependency Injection<br />ASP.NET MVC One Step Deeper<br />
  13. 13. Dependency Injection<br />AccountingCalculations<br />IoC Container<br />JOTaxCalculator<br />ITaxCalculator<br /><ul><li>Example of IoC containers:
  14. 14. Windsor
  15. 15. Ninject
  16. 16. Unity</li></li></ul><li>Dependency Injection<br /><ul><li>Service Locators (hides containers)
  17. 17. IDependencyResolver
  18. 18. GetService
  19. 19. GetServices
  20. 20. DependencyResolver.SetResolver(Object)</li></li></ul><li>Dependency Injection<br /><ul><li>IDependencyResolver</li></li></ul><li>Dependency Injection<br /><ul><li>DependencyResolver.SetResolver(…)</li></li></ul><li>Dependency Injection<br /><ul><li>DI needed in creating Controllers</li></li></ul><li>Dependency Injection<br />DI needed for creating Controllers:<br /><ul><li>No default constructor for StoreController</li></ul>StoreController(IStoreRepository repository)<br />IDependencyResolver kicks in<br />The original IoC container is called through “GetService()”<br />Controller is created<br /><ul><li>No need for ControllerFactory</li></li></ul><li>Filters<br />ASP.NET MVC One Step Deeper<br />
  21. 21. Filters<br /><ul><li>Types of Filters:
  22. 22. Authorization (IAuthorizationFilter)
  23. 23. Action (IActionFilter)
  24. 24. Result (IResultFilter)
  25. 25. Exception (IExceptionFilter)
  26. 26. ActionFilterAttribute: IActionFilter, IResultFilter
  27. 27. Examples of Filters:
  28. 28. Authorize
  29. 29. OutputCache
  30. 30. ChildActionOnly
  31. 31. HandleError
  32. 32. RequireHttps
  33. 33. ValidateAntiForgeryToken</li></li></ul><li>Action Filters<br /><ul><li>Filter Providers, IFilterProvider (MVC 3):
  34. 34. Filters Filters
  35. 35. Can manipulate Filters by DI their properties
  36. 36. Default Filter Providers:
  37. 37. GlobalFilters.Filters
  38. 38. FilterAttributeFilterProvider
  39. 39. ControllerInstanceFilterProvider
  40. 40. You can use multiple Providers</li></li></ul><li>Action Filters<br />Example of Filter Provider<br />
  41. 41. Razor<br />ASP.NET MVC 3 One Step Deeper<br />
  42. 42. Razor<br /><ul><li>Compact, Expressive, and Fluid
  43. 43. Easy to Learn
  44. 44. Is not a new language
  45. 45. Has great Intellisense
  46. 46. Unit Testable</li></li></ul><li>Razor<br />Webforms<br />Razor<br />
  47. 47. Razor<br />Webforms<br />Razor<br />
  48. 48. Razor<br /><ul><li>Multiline statement
  49. 49. Multiline token</li></li></ul><li>Razor<br /><ul><li>Layout (= MasterPages)</li></ul>@RenderBody()<br />@RenderSection(<br />“SectionName”, optional:true<br />)<br />
  50. 50. Razor<br /><ul><li>Content page for Layouts</li></li></ul><li>Razor<br /><ul><li>Content page for Layouts</li></ul>Content<br />@section sectionName<br />{<br />}<br />
  51. 51. Razor<br /><ul><li>_ViewStart.cshtml:
  52. 52. The _ViewStart file can be used to define common view code that you want to execute at the start of each View’s rendering
  53. 53. PageData[“ApplicationTitle”]
  54. 54. @functions
  55. 55. @Url.Content
  56. 56. Razor Inline Templates (Advanced)</li></li></ul><li>HTML Forms<br />ASP.NET MVC 3 One Step Deeper<br />
  57. 57. HTML Forms<br /><ul><li>HTML Helpers (Html.HelperMethod())
  58. 58. ActionLink
  59. 59. BeginForm
  60. 60. CheckBox
  61. 61. DropDownList
  62. 62. Password
  63. 63. Hidden
  64. 64. …</li></li></ul><li>HTML Forms<br /><ul><li>HTML Helpers (Html.HelperMethod())
  65. 65. SelectList</li></li></ul><li>HTML Forms<br /><ul><li>EditorForModel() & EditorFor(m=>m.Property)
  66. 66. Shows proper field types depending on the Model Property types
  67. 67. Properties can be given special behavior through attributes:</li></li></ul><li>HTML Forms<br /><ul><li>UIHint(“NameOfTemplate”)</li></li></ul><li>Q/A<br />Thanks for attending<br />http://www.EmadAshi.com<br />http://www.DotNetArabi.com<br />@EmadAshi<br />
  68. 68. References<br /><ul><li>ASP.NET MVC 3 Dependency Injection
  69. 69. ASP.NET MVC 3 Service Location (series by Brad Wilson)
  70. 70. Action Filters in ASP.NET MVC (by Dino Esposito)
  71. 71. Get to Know Action Filters in ASP.NET MVC 3 Using HandleError
  72. 72. Dependency Injection for Filters in MVC3
  73. 73. Conditional Filters in ASP.NET MVC 3
  74. 74. Introducing “Razor” – a new view engine for ASP.NET
  75. 75. Razor Template in ASP.NET MVC 3
  76. 76. MVC 3 HTML Helpers
  77. 77. Webcamps.ms slides in training kit
  78. 78. Patterns and practices in the Composite Application Library – part 2
  79. 79. Understanding Action Filters</li>

×