INDIA │ 9-11 February 2011virtual techdays SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs
INDIA │ 9-11 February 2011virtual techdays SESSION AGENDA A Brief Overview of ASP.MVC Concepts     Introduction     Rou...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Classic ASP.Net - Main Features      High level abstraction over H...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Classic ASP.Net – Some down sides    Sub‐optimal URLs         blo...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC ASP.NET MVC defined      A new project‐type for VS 2010      A ne...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC ASP.NET MVC defined
INDIA │ 9-11 February 2011virtual techdays  ASP.NET MVC  ASP.NET MVC defined-Browser requests /Products/-Route is determin...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Routing      Routing provides "clean" URLs      URL is mapped to ...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Routing    Developers adds Routes to a global RouteTable    Mappi...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Controller Handling Scenarios, Goals and Design     URLs route to...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Views Scenarios, Goals and Design:    – Are for rendering/output. ...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 The Razor View Engine   – Razor synt...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 Using traditional asp.net code Usin...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 New "ViewBag" Property        MVC 2...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 New "ActionResult" Types     HttpNo...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Dependency Injection Improvements ASP...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Dependency Injection Improvements MVC...
INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Other New Features   NuGet Integratio...
INDIA │ 9-11 February 2011virtual techdays RESOURCES Talk by Scott Hanselmann     http://channel9.msdn.com/posts/matthij...
THANKS│ 9-11 February 2011virtual techdays Kamal.r@marlabs.com
Upcoming SlideShare
Loading in …5
×

Marlabs - ASP.NET Concepts

4,672 views

Published on

Starting with a brief Overview of ASP.MVC concepts, Kamala Rajan walks you through the different features of ASP.NET MVC3

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

No Downloads
Views
Total views
4,672
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Marlabs - ASP.NET Concepts

  1. 1. INDIA │ 9-11 February 2011virtual techdays SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs
  2. 2. INDIA │ 9-11 February 2011virtual techdays SESSION AGENDA A Brief Overview of ASP.MVC Concepts  Introduction  Routing, Controllers & Views A walkthrough of new features in ASP.NET MVC 3  View Engines (Razor)  Unobtrusive Ajax and Unobtrusive Client Side Validation  Dependency resolver
  3. 3. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Classic ASP.Net - Main Features  High level abstraction over HTML / HTTP  Simplified state management  ViewState and the post‐back model  Control model  Data binding  Simple event‐driven mechanism  Simple Page Controller pattern  And lots more as well...
  4. 4. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Classic ASP.Net – Some down sides  Sub‐optimal URLs  blog.aspx?date=21032008  Form runat="server"  ViewState  Hard to test  All sorts of code in the page  Requirement to test with an HttpContext
  5. 5. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC ASP.NET MVC defined  A new project‐type for VS 2010  A new routing mechanism  Applicable not just to ASP.NET MVC  Easier to write using TDD  Clean separation of concerns  NOT a replacement for existing Web Forms  Feel free to completely ignore ASP.NET MVC
  6. 6. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC ASP.NET MVC defined
  7. 7. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC ASP.NET MVC defined-Browser requests /Products/-Route is determined-Controller is activated-Method on Controller is invoked-Controller processes request-Renders View, passing in custom ViewData-URLs are rendered, pointing to other Controllers
  8. 8. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Routing  Routing provides "clean" URLs  URL is mapped to a route handler  Extra level of indirection  Handlers can be changed without impacting URL  URL can be changed without impacting handler  Enables support for multilingual URLs  URL Example : http://www.mysite.com/Home/ProductList
  9. 9. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Routing  Developers adds Routes to a global RouteTable  Mapping creates a RouteData - a bag of key/values public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ); } protected void Application_Start() { RegisterRoutes(RouteTable.Routes); }
  10. 10. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Controller Handling Scenarios, Goals and Design  URLs route to controller “actions”, not pages – mark actions in Controller.  Controller executes logic, chooses view.  All public methods are accessible public void ShowPost(int id) { Post p = PostRepository.GetPostById(id); if (p != null) { RenderView("showpost", p); } else { RenderView("nosuchpost", id); } }
  11. 11. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC Views Scenarios, Goals and Design: – Are for rendering/output. • Pre-defined and extensible rendering helpers – Can use .ASPX, .ASCX, .MASTER, etc. – Can replace with other view technologies: • Template engines (NVelocity, Brail, …). • Output formats (images, RSS, JSON, …). • Mock out for testing. – Controller sets data on the View • Loosely typed or strongly typed data
  12. 12. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 The Razor View Engine – Razor syntax is clean and concise, requiring a minimum number of keystrokes. – Razor is easy to learn, in part because its based on existing languages like C# and Visual Basic. – Visual Studio includes IntelliSense and code colorization for Razor syntax. – Razor views can be unit tested without requiring that you run the application or launch a web server.
  13. 13. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 Using traditional asp.net code Using Razor
  14. 14. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 New "ViewBag" Property  MVC 2 controllers support a ViewData property that enables you to pass data to a view template using a late-bound dictionary API.  In MVC 3, you can also use somewhat simpler syntax with the ViewBag property to accomplish the same purpose.  For example, instead of writing ViewData["Message"]="text", you can write ViewBag.Message="text".  You do not need to define any strongly-typed classes to use the ViewBagproperty.  Dynamic property, you can instead just get or set properties and it will resolve them dynamically at run time.
  15. 15. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3 New "ActionResult" Types  HttpNotFoundResult. Returns a 404 HTTP status code to the client.  RedirectResult. Returns a temporary redirect (HTTP 302 status code) or a permanent redirect (HTTP 301 status code), depending on a Boolean parameter.  HttpStatusCodeResult. Returns a user-specified HTTP status code. JavaScript and Ajax Improvements  By default, Ajax and validation helpers in MVC 3 use an unobtrusive JavaScript approach.  Unobtrusive JavaScript avoids injecting inline JavaScript into HTML.  This makes your HTML smaller and less cluttered, and makes it easier to swap out or customize JavaScript libraries.
  16. 16. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Dependency Injection Improvements ASP.NET MVC 3 provides better support for applying Dependency Injection (DI) and for integrating with Dependency Injection or Inversion of Control (IOC) containers. Support for DI has been added in the following areas: – Controllers (registering and injecting controller factories, injecting controllers). – Views (registering and injecting view engines, injecting dependencies into view pages). – Action filters (locating and injecting filters). – Model binders (registering and injecting). – Model validation providers (registering and injecting). – Model metadata providers (registering and injecting). – Value providers (registering and injecting).
  17. 17. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Dependency Injection Improvements MVC 3 supports the Common Service Locator library and any DI container that supports that librarysIServiceLocator interface. It also supports a new IDependencyResolver interface that makes it easier to integrate DI frameworks. For more information about DI in MVC 3, see the following resources:  http://bradwilson.typepad.com/blog/2010/07/service-location-pt1-introduction.html
  18. 18. INDIA │ 9-11 February 2011virtual techdays ASP.NET MVC New Features in ASP.NET MVC 3Other New Features NuGet Integration Partial-Page Output Caching Granular Control over Request Validation Scaffolding Improvements Sessionless Controller SupportAnd more..
  19. 19. INDIA │ 9-11 February 2011virtual techdays RESOURCES Talk by Scott Hanselmann  http://channel9.msdn.com/posts/matthijs/ASPNET-MVC-2-Basics-Introduction-by-Scott- Hanselman/  Must watch to learn more about MVC Scott Guthrie’s Blog  http://weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview- 1.aspx
  20. 20. THANKS│ 9-11 February 2011virtual techdays Kamal.r@marlabs.com

×