I have the following handler for my c# WebAPI
project.
public class CustomLogHandler : DelegatingHandler
{
[Inject]
public ILogRepository LogRepository { get; set; }
... some methods here
}
This handler is registered in my WebApiConfig.cs
class.
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
... some code here
config.MessageHandlers.Add(new CustomLogHandler());
}
}
Also my ILogRepository is registered in my NinjectWebCommon.cs
class as my other repositories:
kernel.Bind(typeof(ILogRepository)).To(typeof(Data.LogRepository));
The problem is that when I debug and the breakpoint hits my
CustomLogHandler
method,LogRepository
instance is null.
Any clue?