1 / 29

Microsoft ASP.NET MVC 2: The New Stuff

PDC09-FT22. Microsoft ASP.NET MVC 2: The New Stuff. Stephen Walther Senior Program Manager Microsoft Corporation. ASP.NET MVC 1.0. Everything starts so simple, but then…. ASP.NET MVC 1.0. ASP.NET MVC 1.0. Enables you to build applications that can be maintained over the long term:

Samuel
Download Presentation

Microsoft ASP.NET MVC 2: The New Stuff

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. PDC09-FT22 Microsoft ASP.NET MVC 2: The New Stuff Stephen Walther Senior Program Manager Microsoft Corporation

  2. ASP.NET MVC 1.0 Everything starts so simple, but then…

  3. ASP.NET MVC 1.0

  4. ASP.NET MVC 1.0 Enables you to build applications that can be maintained over the long term: • Supports a clear separation of concerns • Supports testability • Supports “close to the metal” programming experience

  5. What’s New in MVC 2? • Better Separation of Concerns (Maintainability) • Html.RenderAction() • Areas • Easier Validation (Maintainability/Productivity) • Data Annotations • Client Validation • Helper Improvements (Maintainability/Productivity) • Strongly-Typed Helpers • Templated Helpers

  6. ASP.NET MVC 2 Visual Studio 2010 Included Visual Studio 2008 (Service Pack 1) Download Both versions built against .NET 3.5

  7. RenderAction(Composability) <% Html.RenderAction() %> • Menus • Banner Ads • Shopping Carts Any UI that appears in multiple pages and requires business logic

  8. RenderAction(Maintainability) • Html.RenderPartial() Renders UI • Html.RenderAction() Invokes controller action that renders UI

  9. Using RenderAction demo

  10. Areas (Maintainability) Areas Enables you to maintain a clear separation of functionality in a single project AreaRegistration.RegisterAllAreas();

  11. Using Areas demo

  12. Validation (Maintainability/Productivity) Client-Side Validation Server-Side Validation Define Validation Model Class

  13. Validation (Maintainability/Productivity) • Model Validation Providers • Data Annotation (Default) • Enterprise Library • XML Anything you want

  14. Validation (Maintainability/Productivity) Data Annotation Validators • [Required] • [Range] • [RegularExpression] • [StringLength] Custom Validator

  15. Validation (Maintainability/Productivity) • public class Customer • { • [Required] • [DisplayName("First Name")] • public string FirstName { get; set; } • [Required] • [RegularExpression(@"\S+@\S+\.\S+")] • public string Email { get; set; } • }

  16. Server-Side Validation with Data Annotations demo

  17. Validation (Maintainability/Productivity) Client-Side Validation <script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script> <script src="../../Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script> <% Html.EnableClientValidation(); %>

  18. Client-Side Validation demo

  19. Strongly-Typed Helpers (Maintainability) • Html.TextBoxFor() • Html.TextAreaFor() • Html.ValidationMessageFor() …

  20. Templated Helpers (Productivity) Display Helper Methods • Html.Display() • Html.DisplayFor() • Html.DisplayForModel() Edit Helper Methods • Html.Editor() • Html.EditorFor() • Html.EditorForModel()

  21. Templated Helpers (Productivity) Specify Template: • By Type: DateTime.ascx • By Name: Html.DisplayForModel(“MyTemplate.ascx”); • By UIHint [UIHint("MyPropertyTemplate")] public string Title { get; set; }

  22. Templated Helpers (Productivity) Fallback: • Employee • Person • Object

  23. Templated Helpers demo

  24. Other New Features • Security • HTML Encoding Syntax • <%:Model.NewPostByEvilPerson%> • Works with ASP.NET 4 • JsonResult • Performance Improvements • Asynchronous Controller Actions • Convenience Improvements • Default Parameters for Controller Actions • HttpPost, HttpGet, RequiresHttps • Value Providers

  25. Value Providers Source for Model Binder data: • FormValueProvider • RouteDataValueProvider • QueryStringValueProvider • HttpFileCollectionValueProvider and custom…

  26. Using a JsonValueProvider with ASP.NET MVC 2 and the Microsoft Ajax Library demo

  27. Why ASP.NET MVC 2 is Great! • Separation of Concerns (Maintainability) • RenderAction() • Areas • Validation (Maintainability/Productivity) • Data Annotations Support • Client Validation • Helper Improvements (Maintainability/Productivity) • Strongly-Typed Helpers • Templated Helpers

More Related