17. Validation Define Validation in Model Server Side Validation Client Side Validation ModelState Class to keep state of model Data Annotation Model Binder Java script
18. Summary RESTful URL Complex URL F ull control over HTML Clean HTML Event - driven programming (Drag n’ drop) Design for testing Cannot test easily Separation of Concerns Combines code and view ASP.NET MVC ASP.NET WebForms
Main purpose of mvc is to isolate business logic from user interface pros - Better maintain - Testable - Cleaner code
Testability - Framework provides interface-base easy to mackable Pluggable - Every component can easy replaced or customize (view replaced with ironPython) - Easy to use dependency injection design pattern (unity, spring) Friendly URL - Can build app for search engine friendly Existing ASP,NET feature still available - All exist asp.net feature still available ex: Master.Page, User Control, Session, Memberdhip - But ViewState and page life cycle are not support Full control of HTML - Write only html - no viewstate Open source - under MS-PL license
Demo from empty project Show create view and run Show ViewData and run Demo TDD hello world
Controller is responsible for handling incoming request - All public method that implement by Controller class, It can be invoke from web via url.
Controller is responsible for handling incoming request - All public method that implement by Controller class, It can be invoke from web via url.
Demo new template project Modify routing default to commentary Create model Commentary Create Commentary controller Create View Show F5 Create Method Details Use Model.Subject
Demo new template project Modify routing default to commentary Create model Commentary Create Commentary controller Create View Show F5 Show feature for HTML helper Show JSON JsonRequestBehavior.AllowGet
Show validation with statemodel Show validation with anotation in serverside Show validation with client
Using ModelState Class => Encapsulates the state of model binding to a property of an action - method argument, or to the argument itself
Uses the ‘Page Controller’ pattern . Each page has a code - behind class that acts as a controller and is responsible for rendering the layout . Uses the ‘Front Controller’ pattern. There is a single central controller for all pages to process web application requests and facilitates a rich routing architecture