Asp.Net Mvc Dev Days09

1,859 views
1,814 views

Published on

It's a presentation that I did in Microsoft Devdays09.

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

  • Be the first to like this

No Downloads
Views
Total views
1,859
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
51
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Asp.Net Mvc Dev Days09

  1. 1. WUX201 - ASP.NET MVC ASP.NET MVC RC1 Bruno Tavares Software Engineer @Sapo.pt
  2. 2. Objectives • A session for developers • Understating the MVC Pattern • Understating the major concepts • Scuba Diving on ASP.NET MVC • Figure out scenarios where it can add value
  3. 3. Sometimes… Editing/developing applications stuff makes me feel like I'm playing “Operation” with my daughter: - It’s very tempting and easy to blend concerns… It’s hard to keep it simple any Clean…
  4. 4. MVC Pattern • MVC - Model/View/Controller • MVC is a architectural pattern Model for Presentation Layer • Isolates business logic from user interface • Clean Separation of Concerns View Controller • Highly maintainable applications
  5. 5. Model MVC Pattern Business Entities What is the Model? Workflow • Responsible for data access, data persistence, data processing, Processing Data business rules, etc. • Agnostic of data presentation Access • Responds to controller requests and notifies views that depend of some model Database Webservice
  6. 6. MVC Pattern What is the View? View Model • Responsible for presentation, look and feel, formatting, sorting, Display(HTML, etc. Render JSON, XML, etc) • A Model can have multiple views Format UI Logic
  7. 7. What is the Controller? Event What is the Controller? Controller • Responsible for handling events, View1 Select View2 manipulate the model and select the Select Select View3 view; Select View • Purpose is to receive a event and figure out what to do with it; Handling event Manipulate Model Model Model
  8. 8. What’s ASP.NET MVC RC1? • Is the first Release Candidate (RC1) • A new Web Project Type for ASP.NET • Gives guidance for structuring web apps • Convention over Configuration • Delivers RESTfull webapplications/websites • Extensible and Pluggable – replace any component of the Framework • Is fully testable (built with TDD in mind) • More control over your <html/>
  9. 9. Where’s ASP.NET going? • Is Microsoft’s ASP .NET going anywhere?
  10. 10. Where’s ASP.NET going? • ASP.NET MVC is just an option built over ASP.NET! – System.Web; – System.Web.MVC;
  11. 11. Choosing Between MVC and WebForms ASP.NET Webforms: • Web Forms is a well-understood technology • Easy to get start • Higher abstraction over HTML • There are many applications where Web Forms work very well – Typical intranet database reporting app – Corporate web applications that all the focus is functionality with constraints like time-to-market – Web Application where presentation components have a lot of dependencies between witch others – vast marketplace of controls many of witch are extremely sophisticated – Backoffices
  12. 12. Choosing Between MVC and WebForms ASP.NET MVC: • For those who like to get dirty over HTML • Lower level or even no abstraction over HTML • Multiple views over the same data (Model) • For websites and web applications that you need to have full control over the output • Use cases examples: – Blogs engines – E-commerce store-front – Vertical front-channels
  13. 13. Choosing Between MVC and WebForms More control over details MVC WebForms ASP.NET • Do it yourself • Control ecosystem • Services • Separation of concerns • State management management • Caching • Test Driven Development • Faster starting point - • Routing • Extensibility everywhere drag and drop • Localization Ready-to- Ready-to-use building blocks
  14. 14. How it works in ASP.NET? Request HTTP Route View Response Routing View Controller Engine
  15. 15. demo -Project Creation -Routing
  16. 16. How controllers and views works?
  17. 17. demos - Controllers and Views - ActionFilters and ResultActions - Build a ViewEngine
  18. 18. NHaml #foo - foreach (var product in ViewData) - if (product.Category.CategoryName != null) %h2=product.Category.CategoryName - break %ul.productlist - foreach (var product in ViewData) %li = Html.Image(quot;/Content/Images/quot; + product.ProductID + quot;.jpgquot;, product.ProductName) .productdetail =Html.ActionLink(product.ProductName, quot;Detailquot;, new { ID=product.ProductID }) %br Price: =String.Format(quot;{0:C2}quot;, product.UnitPrice) “.productdetail” %span.editlink ( =Html.ActionLink(quot;Editquot;, quot;Editquot;, new { ID=product.ProductID }) ) becomes <div id=”productdetail”>
  19. 19. Spark <ul class=quot;productlistquot;> <var styles='new[] {quot;oddquot;, quot;evenquot;}'/> <li each=quot;var product in ViewData.Modelquot; class=quot;${styles[productIndex%2]}quot;> <ProductImage style='quot;float:left;quot;'/> <p> <a href=quot;/Products/Detail/${product.ProductID}quot;>${product.ProductName}</a> <br /> Price: ${String.Format(quot;{0:C2}quot;, product.UnitPrice)} <span class=quot;editlinkquot;> (${Html.ActionLink[[ProductsController]](c=>c.Edit(product.ProductID), quot;Edi tquot;)}) </span> </p> <div style=quot;clear:both;quot;></div> </li> </ul> <li each=quot;var product in ViewData.Modelquot; class=quot;${styles[productIndex%2]}quot;>
  20. 20. What's Next in MVC? • Enterprise scaling features – More control over session state – Asynchronous controller actions • Lambda-based helpers
  21. 21. Conclusion • Fine-grained control over HTML • It’s extensible and pluggable – add or change for what you like • Clear separation of concerns • Testability - support for Test-Driven Development • ASP.NET MVC is an OPTION over ASP.NET webforms
  22. 22. Q&A
  23. 23. Software em versão completa para avaliação Suporte técnico 24x7 para incidentes Acesso antecipado às versões beta Microsoft Office Software Assurance formação gratuita ….e muito mais. w w w. m i c r o s o f t . c o m / p o r t u g a l / m s d n / s u b s c r i c o e s
  24. 24. w w w. m i c r o s o f t . c o m / l e a r n i n g / m c p / o f f e r s / s e c o n d s h o t
  25. 25. MSDN Flash w w w. m i c r o s o f t . c o m / p o r t u g a l / m s d n / m s d n f l a s h
  26. 26. Participe nos próximos ciclos Traga Amigos a assistir e … …ganhe uma Xbox, trolleys e livros w w w. m i c r o s o f t . c o m / p o r t u g a l / m s d n / w e b c a s t s 4 s h a r e
  27. 27. [BI] Resort GASP GetCertified GetVirtual Mundo Móvel PocketPT PontoNetPT UC’ed ScrumPT ZoomIn
  28. 28. Questionário A sua opinião é importante! Complete o questionário de avaliação e devolva- devolva-o no balcão da recepção.
  29. 29. Instituto Superior Técnico Campus do Taguspark

×