You can access the IKernel
configured by NinjectWebCommon.cs
anywhere in your application. Of course, this usually is not recommended since it's a smell of Service Locator anti-pattern.
But there are cases where we can't escape from it, specially when mixing the frameworks and in your composition root, it's ok.
So, wherever you need, just use:
using Ninject;
//My class that will need access to the IKernel
var kernel = (new Bootstrapper()).Kernel;
The Bootstrapper
class is initialized in App_Start.NinjectWebCommon
before even the Application_OnStart
runs. So it is safe to use even in Global.asax
to obtain a reference to the IKernel
. It remembers the kernel instance that was provided to it via a static variable inside the Bootstrapper class.
Hope that helps!