Targeting Mobile Platform with MVC 4.0
Upcoming SlideShare
Loading in...5

Like this? Share it with your network


Targeting Mobile Platform with MVC 4.0






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Targeting Mobile Platform with MVC 4.0 Presentation Transcript

  • 1. © 2009 SPR Companies. All rights reserved. MPS Partners An SPR Company Brown Bag Series – 4/10/2012: Targeting Mobile Platform with MVC 4.0 by Mayank Srivastava
  • 2. ASP.NET MVC 4 Beta • HTML 5, a required part of the deal • Mobile Project Templates • Display Modes • jQuery Mobile, View Switcher, browser overriding • Recipes • Task<> to support Asynch Controllers • Bundling support • Web API Templates • Single Page Applications • ~/URL Resolution
  • 3. So what is MVC pattern? Image from Model-View-Controller is an architectural pattern that isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).
  • 4. Basics ASP.NET Web Forms + MVC Pattern = ASP.NET MVC ASP.NET + MVC Pattern = ASP.NET MVC ASP.NET == ASP.NET Web Forms
  • 5. ASP.NET - The Song Remains The Same
  • 6. Web Forms Request (*.aspx) PageHandlerFactory Responsible for page processing engine Create a server form Execute Page life cycle Load View state / Control state Server Form / Page Response (Browser understandable content) Inheriting System.Web.UI.Page does the trick.
  • 7. So what is MVC pattern? Model • Domain-specific representation of data • Business logic • Storage layer is an implementation detail
  • 8. So what is MVC pattern? View • Presents data to the user • Read-only views as well as forms • Minimal display-only logic
  • 9. So what is MVC pattern? Controller • Responds to requests • Connects models to view • Invokes model code as appropriate
  • 10. MVC based ASP.NET framework Request (URL) Controller Response (Browser understandable content) Model View -> Get the model (if needed) -> Bind the model to the view (if needed) ->Render the view Viewsknowhowtopresentmodels Other related frameworks -
  • 11. So what changed… No Page life cycle • No Server page, no server controls, only Views! • Web is state ‘LESS’ environment. • An asynchronous call should be an asynchronous call. No View state • Again, web is state ‘LESS’ environment. • In hindsight, for the stateless web - state should be Model’s responsibility, not View’s overhead. No Postback • Only Http verbs – Get, Post, Put, Delete.
  • 12. Over to Visual Studio
  • 13. A Quick comparison • • Asynchronous when you need Synchronous when you don’t Web Forms MVC Try reload / paging on Telerik’s WebForm’s Grid and compare the performance against Telerik’s MVC grid.
  • 14. Page 14 Some more Super Hero talk
  • 15. Page 15 Routing It’s all about Routes, not file path.  Application/Controller/Action/Parameter  Or whatever you want  Search Engine Optimization  Imagine possibilities –  Windows Workflow Foundation  RSS feeds  Window communication foundation  The Browse / Ajaxify Pretty much anything!
  • 16. Over to Visual Studio
  • 17. Page 17 Deeper dive Oh and by the way – ASP.NET MVC, aka System.Web.Mvc, is Open Source Check out the code on :-
  • 18. Page 18 Frequently bought together Customers Who Bought This Item Also Bought • n-Tier application architecture (Separation of concern). • IoC – Inversion of control (Dependency injection). • TDD – Test Driven Development. 18
  • 19. Page 19 Separation of Concern What concern? Why are you concerned? My application works fine! Remember Models?
  • 20. Page 20 Separation of concern Model Nothing but POCO Domain-specific representation of data Domain Models Business logic Business Layer Storage layer is an implementation detail Data Access Layer
  • 21. Page 21 Separation of concern Most Common (rather default) Design Patterns • Services Based for extendibility • Repositories for Data Access Layer
  • 22. Page 22 DI & IoC Dependency injection (Image - • Static kernel based container • Control over scope (singleton, Request) • Popular frameworks – Unity (Enterprise Library), StructureMap, Ninject, Castle Windsor, Spring.NET…
  • 23. Page 23 Inversion of Control Database Web Client Services Repositories ICacheService ICacheRepository WP7 App Facebook Canvas Use HttpCacheService : ICacheService & SQLCacheRepository : ICacheRepository Use WPCacheService : ICacheService & LocalFileCacheRepository : ICacheRepository Use WPCacheService : ICacheService & LocalFileCacheRepository : ICacheRepository How should I handle your cache needs?
  • 24. Page 24 Test Driven Development Why is it the big breakthrough? Is it testable? – No… (at least not easily) Is it testable? – Yes! var product = new ProductController(); var result = product.List();
  • 25. Page 25 Why MVC • App Driven Development • Industry moving towards Usability • It’s all about user experience Usability = (Functionality ^ Look) * Feel;
  • 26. Page 26 Future? Is this the end of Web Forms? Now that MVC is here. No! That’s ridicules! (as on
  • 27. Page 27 Future? Flashback Is this the end of VB? Now that C# is here. No! That’s ridicules! However VB can’t be used on some cool stuff like Window Phone, the .NET Micro Framework err…I mean VB is equally good.
  • 28. Page 28 Resources Learning Resources: Prominent bloggers: Scott Guthrie - Scott Hanselman - Phil Haak - Rob Conery - Jon Galloway - Stevens Anderson - Brad Wilson - Also: Me :) -
  • 29. Page 29 Questions