It\'s a Web API 2 project.
When I implement DI using Ninject, I got an error message
An error occurred when trying to create a controller of type \'TokenCont
We use the standard ninject.MVC5 package installed with nuget
PM> install-package ninject.MVC5
Then we configure our bindings like so.
kernel.Bind()
.To()
.InRequestScope();
kernel.Bind>()
.To>()
.InRequestScope();
kernel.Bind()
.To()
.InRequestScope()
.WithConstructorArgument("ApplicationName");
kernel.Bind().ToSelf().InRequestScope()
.WithPropertyValue("UserTokenProvider",
new DataProtectorTokenProvider(
kernel.Get().Create("EmailConfirmation")
));
You may need to adjust dependent on how much you have customized your user model. For instance the user store binding may be something like.
kernel.Bind>()
.To().InRequestScope();
Also any setting up of the user manger you require i.e. password policies can be set in your user manager constructor.
Previously this could be found in the create method in the sample, you will no longer require this. also you can now get rid of the owin get context calls as ninject will handle resolution for you.