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