I'm using Ninject 3.0 to inject service layer data access classes into my controllers. I would like to add the client's domain user ID to these classes at runtime, but cannot figure out what approach I should use. Currently my NinjectModule
looks something like this:
public class NinjectBindModule : NinjectModule
{
public override void Load()
{
Bind<ISomeRepo>().To<SomeRepo>();
}
}
My question, in two parts really is:
- Should I use
WithConstructorArgument
to get the user ID intoSomeRepo
, or something else (property?). Can I even do this in the bind module, or does it have to be done at the kernel or controller level? - What method should I use to retrieve the client's domain user ID? I don't think I can use the Controller.User property at the kernel level or in the bind module, can I?