I'm not very experienced with Ninject, so I may have a concept completely wrong here, but this is what I want to do. I have a multi-tenant web application and would like to inject a different class object depending on what URL was used to come to my site.
Something along the lines of this, although maybe I can use .When() in the binding, but you get the idea:
private static void RegisterServices(IKernel kernel)
{
var currentTenant = TenantLookup.LookupByDomain(HttpContext.Current.Request.Url.Host.ToLower());
if (currentTenant.Foldername == "insideeu")
{ kernel.Bind<ICustomerRepository>().To<AXCustomerRepository>(); }
else
{ kernel.Bind<ICustomerRepository>().To<CustomerRepository>(); }
...
The problem is that HttpContext.Current is null at this point. So my question is how can I get the HttpContext data in NinjectWebCommon.RegisterServices. Any direction on where I might be going wrong with Ninject would be much appreciated as well.
Thank you