400 likes | 530 Views
ASP.NET MVC 2. The good news. Jean-Claude Trachsel Senior Consultant, Trivadis AG j ean-claude.trachsel@trivadis.com. Agenda. What is ASP.NET MVC Features of Version 2 What about the «real life»? Summary. What is ASP.NET MVC. A short introduction.
E N D
ASP.NET MVC 2 The good news Jean-Claude Trachsel Senior Consultant, Trivadis AG jean-claude.trachsel@trivadis.com
Agenda • What is ASP.NET MVC • Features of Version 2 • What about the «real life»? • Summary
What is ASP.NET MVC A short introduction
Framework based on Model-View-Controller Pattern Separation of Concerns Framework is focusing on... Pure Web Development Stateless, no ViewState Full control over markup Testability TDD, Unit Tests Maintainability Extensibility and Flexibility Modern aspects like AOP, DI, IoC What is ASP.NET MVC
Positioning ASP.NET MVC • ASP.NET MVC • ASP.NET Web Forms ASP.NET Framework .NET Framework
Visual Studio Template Controller and View Unit Test Demo
Features of Version 2 Areas, Validation, Typed UI Helpers, etc.
Goals of the DevTeam for Version 2 More Productivity More Security More Performance More Extensibility MoreHappiness What do we get?
What we will look at • Areas • Validation • Typed UI Helpers • UI Helper Templates • Async Controllers
Areas Single Project and Multi Project Areas
Enterprise ready with Areas Structure your Solution with... Single Project Area Multi Project Area Easy re-use of Code Areas – what for?
Single Project Area Folder Structur Route Class Inherits from AreaRegistration Defines the route to the Controller Global.asax Register the area routes Areas – what’s needed?
Single Project Areas Demo
Validation Data Annotations Attributes
Data Validation with DataAnnotations Attributes Introduced with .NET 3.5 SP 1 Benefits of DataAnnotations Attributes Set in one central place, on the model Used by different Technologies Used in ASP.NET Dynamic Data Used in WCF RIA Services ASP.NET MVC Validation
Use of DataAnnotations • Set Attributes on the Model • [MetadataType(typeof(ProductMetadata))] • publicpartialclassProduct • { • } • publicclassProductMetadata • { • [Required] • publicstring Name { get; set; } • }
Attributes that are available Required Range RegularExpression StringLength CustomValidation Build your own DataAnnotations
Server Site Validation ModelBinder Class Client Site Validation jQuery Validation Library Validation in ASP.NET MVC
Validation with DataAnnotation Attributes Server- and Client Site Demo
Typed UI Helpers ...and the UI Helper Templates
HtmlHelper Extensions ASP.NET MVC 1 ASP.NET MVC 2 Typed UI Helpers <%=Html.TextBox(„ProductID“,Model.ProductID)%> <%=Html.Label(„Name“,Model.Name)%> <%=Html.RadioButton(„Avail“,Model.Available)%> <%=Html.DisplayFor(p => p.ProductID)%> <%=Html.Ed itorFor(p => p.ProductID)%>
Benefits are... Intellisense Compile Time Support Type based rendering Support for standard and complex types Typed UI Helpers
Extend the Typed UI Helper Methods Define the Rendering via UserControls Supports standard and complex types Used by... Name Convention UI Helper Method Parameter ViewModel Attributes UI Helper Templates
Typed UI Helpers UI Helper Template for DateTime Demo
Async Controllers Be smart, be fast
Use of Async Controller publicclassHomeController : AsyncController { publicvoidNAMEAsync() { AsyncManager.OutstandingOperations.Increment(3); // Do all Tasks asynchronouse } publicActionResultNAMECompleted(object params) { // Do final work returnView("NAME"); } }
Async Controller is a Server Side Pipeline For Async Clinet/Server Requests use AJAX Do Multiple Tasks at once Get data from different stores at the same time Prevent Blocking of the Webserver Worker Threads are not blocked No Thread starvation Async Controllers
Use synchronouse pipelines Operations are simple or short-running Simplicity is important Use asynchronouse pipelines Operations are network-bound or I/O-bound Parallelism is important Provide a mechanism to cancel long-running request Async Controllers
Async Controllers Demo
What about «real life»? Experience from current projects
It’s a Paradigm Shift Can be hard forMS Win-/WebForms Developers Easier for PHP, Java, etc. Developers It’s a lot of Client Side Programming New Know-How is needed Learn ASP.NET MVC
Convention over Configuration Easy to understand New Team Members Maintenance More Unit Tests Better Quality Less Bugfixing Better Reusability Productivity – the good side
No reuse of existing... Concepts Frameworks Controls Loss of Functionality (GUI)Libraries Productivity – the down side
Summary & Resources 3, 2, 1, go
New Web Development Paradigm perfect for... TDD, Large Projects and Teams Many new Features to gain... Productivity and happiness Use ASP.NET MVC When ever you can Use ASP.NET WebForms Need to use existing Frameworks, Libs or Controls No time to establish needed Know-How Summary
Productivity Tasked based helpers Validation Improvements Ajax Multiple Partial Updates Client Templates Support Architecture Dependency Injection at all levels MEF Controller (Managed Extensibility Framework) Performance Improved Caching More Control over Session ASP.NET MVC 3
Websites http://www.asp.net/mvc http://www.codeplex.com/aspnet Blogs http://www.haacked.com/ http://weblogs.asp.net/scottgu http://www.hanselman.com http://stephenwalther.com/blog Resources
Thank you for your Attention! • For more Information please contact • Jean-Claude Trachsel • Senior Consultant • jean-claude.trachsel@trivadis.com • 076 4000 900 • Trivadis AG • Europastrasse 5 • 8152 Glattbrugg
BesuchenSieunseren Stand Trivadis Innovation Partnership Programm (TIPP) Gemeinsame Innovations-Projekte Trainings Voucher für 1 Schulungstag (Wert CHF 870.-) SharePoint 2010 SQL Server 2008 R(2)efreshed Business Intelligence mit Microsoft in 2010 Talent Scout Herausfordernde, attraktive Jobs warten MeldenSiesich!