Csla 3.8 Model Binder
Old forum URL: forums.lhotka.net/forums/t/8047.aspx
xAvailx posted on Wednesday, November 25, 2009
I am trying to get my feet wet on MVC & CSLA.
I see in Csla 3.8 there is a custom model binder, how would I go about using the custom model binder? xAvailx replied on Wednesday, November 25, 2009
Figured out one way...
In Application_Start
ModelBinders.Binders.DefaultBinder = new Csla.Web.Mvc.CslaModelBinder();
Now that works, however would like to be a bit more specific. I tried:
ModelBinders.Binders.Add(typeof(Csla.Core.IBusinessObject), new Csla.Web.Mvc.CslaModelBinder());
and
ModelBinders.Binders.Add(typeof(Csla.Core.BusinessBase), new Csla.Web.Mvc.CslaModelBinder());
But that didn't work, any tips?
Clarification:
What doesn't "work" is that I get duplicate messages for each broken rule.RockfordLhotka replied on Wednesday, November 25, 2009
The default model binder generates duplicate messages, at least if you use validation attributes.
I have only set the DefaultBinder myself, but it could easily be that ASP.NET MVC doesn't work against interfaces or base classes, and only registers a binder for a concrete type?
Copyright (c) Marimer LLC