You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But now I can see that the constructor is being called several times, therefore I will have several IKernel, and I guess that singleton instances won't be so singleton in my app scope.
I'm starting a web application with MVC3 and Ninject. There is one dependency that I also need in the Global.asax file that needs to be a singleton.
I thought it should be like this:
public class MvcApplication : NinjectHttpApplication
{
IUserAuthentication _auth;
But then I saw that _auth is null when MvcApplication_AuthenticateRequest is called.
Then I tried like this:
public class MvcApplication : NinjectHttpApplication
{
ItUserAuthentication _auth;
IKernel _kernel;
But now I can see that the constructor is being called several times, therefore I will have several IKernel, and I guess that singleton instances won't be so singleton in my app scope.
How should I do it? Using a static variable?
I put this question also in http://stackoverflow.com/questions/5512040/ninject-ing-a-dependency-in-global-asax
The text was updated successfully, but these errors were encountered: