Agenda
What is ASP.NET MVCFeatures of Version 2What about the «real life»?Summary
What is ASP.NET MVC
A short introduction
Framework based on Model-View-Controller PatternSeparation of Concerns
Framework is focusing on...Pure Web Development
Stateless, no ViewStateFull control over markup
TestabilityTDD, Unit Tests
MaintainabilityExtensibility and Flexibility Modern aspects like AOP, DI, IoC
What is ASP.NET MVC
Positioning ASP.NET MVC
ASP.NET Web FormsASP.NET MVC
ASP.NET Framework
.NET Framework
Visual Studio TemplateController and ViewUnit 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
More Happiness
What do we get?
What we will look at
AreasValidationTyped UI HelpersUI Helper TemplatesAsync 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))]public partial class Product{}
public class ProductMetadata{ [Required] public string 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 AttributesServer- and Client Site
Demo
Typed UI Helpers
...and the UI Helper Templates
HtmlHelper ExtensionsASP.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 HelpersUI Helper Template for DateTime
Demo
Async Controllers
Be smart, be fast
Use of Async Controllerpublic class HomeController : AsyncController{ public void NAMEAsync() { AsyncManager.OutstandingOperations.Increment(3); // Do all Tasks asynchronouse }
public ActionResult NAMECompleted(object params) { // Do final work return View("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 for MS 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 ConfigurationEasy to understand
New Team MembersMaintenance
More Unit TestsBetter QualityLess 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 MVCWhen ever you can
Use ASP.NET WebFormsNeed to use existing Frameworks, Libs or ControlsNo time to establish needed Know-How
Summary
Productivity Tasked based helpersValidation Improvements
Ajax Multiple Partial UpdatesClient Templates Support
ArchitectureDependency Injection at all levels MEF Controller (Managed Extensibility Framework)
Performance Improved Caching More Control over Session
ASP.NET MVC 3
Websiteshttp://www.asp.net/mvchttp://www.codeplex.com/aspnet
Blogshttp://www.haacked.com/http://weblogs.asp.net/scottguhttp://www.hanselman.comhttp://stephenwalther.com/blog
Resources
Thank you for your Attention!For more Information please contact
Jean-Claude TrachselSenior Consultant
[email protected] 4000 900
Trivadis AGEuropastrasse 58152 Glattbrugg
SharePoint 2010SQL Server 2008 R(2)efreshedBusiness Intelligence mit Microsoft in 2010
Trainings Voucher für 1 Schulungstag (Wert CHF 870.-)
Talent Scout
Herausfordernde, attraktive Jobs warten Melden Sie sich!
Besuchen Sie unseren Stand
Trivadis Innovation Partnership Programm (TIPP)Gemeinsame Innovations-Projekte
Top Related