In my NinjectDependencyresolver
I have this:
public NinjectDependencyResolver(IKernel kernelParam)
{
this.kernel = kernelParam;
AddBindings();
}
private void AddBindings()
{
kernel.Bind<IProductsRepository>().To<EFProductRepository>();
}
and then in my controller
class I have this:
public class ProductController : Controller
{
private IProductsRepository repository;
public int PageSize = 4;
public ProductController()
{
}
public ProductController(IProductsRepository productRepository)
{
this.repository = productRepository;
}
The problem is that the repository
is null
Also If I add a break point to the AddBinsings() method
, it doesn't get hit before going to the controller, controller
gets hit but AddBindings()
does not.
So does it mean it is a problem with my Ninject
?
ALSO: I added the parameter less constructor
of ProductController
after getting this error:
No parameterless constructor defined for this object
I don't think I need that constructor, but if I remove it I get that error.
Should have also called it in
Gloabal.ashx.cs
file