ÖreDev Day 4 – Afternoon
November 5, 2009
I’m still feeling a bit exhausted from Dan North’s previous talk, but now it’s time for some more down-to-earth coding topics.
Putting the M of ASP.NET MVC with Scott Allen
Scott Allen started by discussing the role of the model in ASP.NET MVC and its intended audience:
- Business objects can be useful, especially when building wrappers around SQL Management Studio, but they may not always serve the best purpose in MVC applications.
- The model often has to cater to both the view and the business logic. To address this, Scott recommends creating a view model. While this may lead to many classes, it ensures that each class has a well-defined responsibility.
- You can define an interface to specify which properties should be bound when using TryUpdateModel<T>.
- Instead of using IModelBinder for model binding, which can be cumbersome, override OnModelUpdated on the default model binder...