Your SlideShare is downloading. ×
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
ASP.NET MVC One Step Deeper
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

ASP.NET MVC One Step Deeper

3,458

Published on

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. …

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.

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

No Downloads
Views
Total Views
3,458
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Model is ignorantView knows about Model onlyController knows about both Model and View
  • Image from Dino Esposito’s article
  • Check the references to see where from this figure was used
  • Service Locators will act as a layer over Dependency Injection containersYou have to implement IDependencyResolver in order to use the container you want and add any specific logic you might need, though it’s advised not to go too sophisticated thereNinject will implmentIDependencyResolver for youYou will call DependencyResolver.SetResolver to set the resolver Dah!Each part of MVC will use this Service Locator and in the way it sees fit; Controllers have DefaultControllerActivator that uses your new implementation of IDependencyResolver, View have DefaultViewPageActivator, …etc.
  • Service Locators will act as a layer over Dependency Injection containersYou have to implement IDependencyResolver in order to use the container you want and add any specific logic you might need, though it’s advised not to go too sophisticated thereNinject will implmentIDependencyResolver for youEach part of MVC will use this Service Locator and in the way it sees fit; Controllers have DefaultControllerActivator that uses your new implementation of IDependencyResolver, View have DefaultViewPageActivator, …etc.
  • Better Inherit from “ActionFilterAttribute” if you need to do attribute filterIf you want to do Authorization filter consider inheriting from “FilterAttribute” classFilters can decorate an Action, a Controller (ControllerInstance), and to be global Authorize: checks to see whether the current user is logged in, and matches a provided username or role name (or names), and if not it returns a 401 status, which in turn invokes the configured authentication providerChildActionOnly: used to indicate that the action method may only be called as part of a parent request, to render inline markup, rather then returning a full view template.OutputCache: tells ASP.NET to cache the output of the requested action, and to serve the cached output based on the parameters provided. HandleError: provides a mechanism for mapping exceptions to specific View templates, so that you can easily provide custom error pages to your users for specific exceptions (or simply have a generic error view template that handles all exceptions). RequireHttps: forces a switch from http to https by redirecting GET requests to the https version of the requested URL, and rejects non-https POST requestsValidateAntiForgeryToken: checks to see whether the server request has been tampered with. Used in conjunction with the AntiForgeryToken HTML Helper, which injects a hidden input field and cookie for later verification
  • Filter Providers are filters of Filters by which you can manipulate filters before action
  • You can inherit from a Provider (e.g. FilterAttributeFilterProvider) and override GetFilters().AsEnumerabe<Filter>() something I learned by reading blogs and trying code out. I can’t recall when or how, but this shows how important reading blogs and trying code out is, I would have had hard time figuring how to return an IEnumerable the way I wanted
  • Razor knows where to break
  • PageData to pass data to the Layout page@functions you can declare code thereUse @Url.Content for proper path
  • Html Helpers are Extension methods that will make it easy to render html code for different uses (displaying links, fields, etc…)
  • A SelectList instance can be used to populate the list with the default value
  • UIHint is an attribute used to decorate a property in the Model class, will specify the name of the control to be used to display/edit the property
  • Transcript

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

    ×