1 / 15

ASP.NET MVC Extensibility

ASP.NET MVC Extensibility . Customizing ASP.NET MVC Applications NYC Code Camp 2010-03-06. John Zablocki Development Lead MagazineRadar, Inc. john@zblock.net. We thank the following companies for their gracious sponsorship. Platinum Sponsors. Gold Sponsor. Agenda.

hazina
Download Presentation

ASP.NET MVC Extensibility

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ASP.NET MVC Extensibility Customizing ASP.NET MVC Applications NYC Code Camp 2010-03-06 John Zablocki Development Lead MagazineRadar, Inc. john@zblock.net

  2. We thank the following companies for their gracious sponsorship Platinum Sponsors Gold Sponsor

  3. Agenda • ASP.NET Default Architecture • ASP.NET Extension Points • HtmlHelper Extensions • Controller Factories • View Engines • Filters • ASP.NET MVCContrib • Questions

  4. ASP.NET MVC Defaults • View Engine • WebForms View Engine • HtmlHelper • ViewData and TempData • Controllers • Invoked via convention based on route data • ViewData and TempData

  5. HtmlHelper Extension Methods • Html property of MvcViewPage is an instance of HtmlHelper class • Allows for encapsulation of markup and scripts • HtmlHelper instance has access to ViewData and TempData via ViewContext • Methods may return strings or emit markup • <%=Html.Method() %> vs. <% Html.Method(); %> • Demo: Simple JavaScript Dialog Extensions

  6. Custom Controller Factories • Use to create custom IController instances • Often used to work with IoC Containers • Implement IControllerFactory interface • CreateController returns instance of an IController • ReleaseController for cleaning up • Set custom factory in in application start using ControllerBuilder.SetControllerFactory • Demo: PigLatinControllerFactory

  7. Custom View Engine • Allows for non-Web forms view engines • Implement IViewEngine interface • Abstract methods for finding & releasing views • Implement IView interface • Abstract Render method • Custom IViewEngine returns ViewEngineResult that uses custom IView • Demo: A Simple ViewEngine

  8. Action Filters • Allow code to be wrapped around controller actions and view results • Similar to HttpModules • Provide a mechanism for removing cross cutting code (logging, authorization, etc.) from controller classes • Demo: SitePerformanceFilter

  9. ASP.NET MVCContrib • Open source project hosted at CodePlex • Enhancements on top of standard MVC • HtmlHelper extensions • IoC controller factories • Alternative ViewEngines • VS.NET Code snippets and more • Integration points with several other open source projects (NVelocity, Spring.NET, etc.)

  10. MVCContrib UI Helpers • FluentHtml Helpers • Fluent API for generating markup • Helper methods of the View, not HtmlHelper • Type safety with strongly typed view • Grid Helper • HtmlHelper for generating grids of model data • Fluent API • Demo: UI Helpers

  11. MVCContrib Controller Factories • Allows controllers and controller dependencies to be managed by IoC container • Support for several popular containers • Spring.NET • Castle Windsor • Structure Map • Unity • Demo: Spring.NET Controller Factory

  12. MVCContrib View Engines • Provides support for several alternative view engines (using popular templating engines) • Brail • NHaml • NVelocity • Spark • Demo: Brail View Engine

  13. MVContrib Filters • PreCondition Filter • Rescue Filter • Layout Filter • Demo: PreCondition Filter

  14. Resources • http://www.codevoyeur.com – DLR Samples, other OSS samples, presentations and articles • http://www.dllhell.net – My blog • http://mvccontrib.codeplex.com/ • http://www.asp.net/mvc

  15. Questions?

More Related