おそらく、DefaultModelBinderから継承し、Ninjectを介してモデルクラスを解決しますか?
アップデート:
NinjectModelBinder.cs
public class NinjectModelBinder : DefaultModelBinder
{
private readonly StandardKernel _kernel;
public NinjectModelBinder(StandardKernel kernel)
{
_kernel = kernel;
}
protected override object CreateModel(ControllerContext controllerContext,
ModelBindingContext bindingContext, Type modelType)
{
var model = _kernel.TryGet(modelType);
if (model != null) return model;
return base.CreateModel(controllerContext, bindingContext, modelType);
}
}
Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
var kernel = new StandardKernel();
ModelBinders.Binders.DefaultBinder = new NinjectModelBinder(kernel);
}
}