I want to configure my model binders with Nhibernate:
So I have:
<object id="GigModelBinder" type="App.ModelBinders.GigModelBinder, App.Web" singleton="false" >
<property name="VenueManager" ref="VenueManager"/>
<property name="ArtistManager" ref="ArtistManager"/>
I have an attribute which marks controller actions so that they use the correct model binder i.e.
[AcceptVerbs("POST")]
public ActionResult Create([GigBinderAttribute]Gig gig)
{
GigManager.Save(gig);
return View();
}
This works fine and my GigModelBinder has the correct VenueManger and ArtistManager injected
However if in application Start I add:
System.Web.Mvc.ModelBinders.Binders.Add(typeof(App.Shared.DO.Gig), new GigModelBinder());
and in a controller action use :
UpdateModel<Gig>(gig);
for example:
[AcceptVerbs("POST")]
public ActionResult Update(Guid id, FormCollection formCollection)
{
Gig gig = GigManager.GetByID(id);
UpdateModel<Gig>(gig);
GigManager.Save(gig);
return View();
}
The VenueManger and ArtistManager has NOT been injected into the GigModelBinder.
Any ideas what I'm doing wrong?