Inject a dependency into a custom model binder and using InRequestScope using Ninject

The ModelBinders are reused by MVC for multiple requests. This means they have a longer lifecycle than request scope and therefore aren’t allowed to depend on objects with the shorter request scope life cycle.

Use a Factory instead to create the IPostRepository for every execution of BindModel

Leave a Comment