1 / 9

Componentizing ASP.NET MVC

Componentizing ASP.NET MVC. Simone Chiaretta Solution Developer, Avanade http://codeclimber.net.nz. 27 Giugno 2009. Who the hell am I?. Simone Chiaretta Lavoro per Avanade Italy Microsoft MVP ASP.NET Blogger – http://codeclimber.net.nz Founder of UGIALT.NET OpenSource developer

Download Presentation

Componentizing ASP.NET MVC

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. Componentizing ASP.NET MVC Simone ChiarettaSolution Developer, Avanade http://codeclimber.net.nz 27 Giugno 2009

  2. Who the hell am I? • Simone Chiaretta • Lavoro per Avanade Italy • Microsoft MVP ASP.NET • Blogger – http://codeclimber.net.nz • Founder of UGIALT.NET • OpenSource developer • Climber • All Around Nice Guy

  3. How to componentize ASP.NET MVC • RenderPartial • The controller must “create” all the data needed by all components • RenderAction (MvcFutures) • Smells (the view knows about the controller) • Difficult to test that the component is displayed • Custom HtmlHelpers • Good for building HTML, must not have logic BAD BAD BAD • RenderPartial + Action Filters • Data “creation” is encapsulated, view is encapsulated GOOD

  4. What’s an action Filter • It’s an Attribute • Allows code execution (AOP style) • During the Authentication phase • When an Exception is thrown • Before an Action • After an Action • Before the rendering of a View • After the rendering of a View • “Core” filters • Authorize • HandleException • OutputCache

  5. Action Filter + Render Partial • Controller: • Executes the code only for its “main concern” and “create” the main data • View: • Shows the “main” output • Calls all the PartialViews • Action Filters: • Load data for the partial views • Partial views • Shows the data retrieved by the Action Filters

  6. [DEMO] Action Filter + Render Partial

  7. The Shameless Plug: Beginning ASP.NET MVC • Simone Chiaretta e Keyvan Nayyeri • Released on: August 3° 2009 • Already for pre-sale on Amazon • TOC: • MVC • Testing • And more... • http://www.amazon.com/Beginning-ASP-NET-MVC-Simone-Chiaretta/dp/047043399X/

  8. Contacts – Simone Chiaretta • MSN: simone_ch@hotmail.com • Blog: • English: http://codeclimber.net.nz/ • Italiano: http://blogs.ugidotnet.org/piyo/ • Twitter: http://twitter.com/simonech

  9. Q&A

More Related