Ninject Object Scopes

If you want to set a specific resolution to:

  • Transient
  • Singleton
  • Per Request

Details on the Ninject Github wiki

How to Use Ninject Object Scopes

Add one of the commands to the end of your bind code, below. For example:

kernel.Bind<ISomeService>().To<SomeImplementation>().InSingletonScope;

Singleton

.InSingletonScope()

New instance of the type will be created each time one is requested. (default)

Transient

.InTransientScope()

Single instance of the type will be created, and the same instance will be returned for each subsequent request.

Per Request

.InRequestScope()

One instance of the type will be created for each Web Request.