我在我的 NinjectWebCommon.RegisterServices 方法中为 HttpContextBase 创建了一个绑定,但是当我尝试在我的控制器或服务中引用它时,我收到一条错误消息。
这是绑定:
kernel.Bind<HttpContextBase>().ToMethod(context => new HttpContextWrapper(HttpContext.Current)).InRequestScope();
这是错误消息:
Error activating HttpContextBase
More than one matching bindings are available.
Activation path:
2) Injection of dependency HttpContextBase into parameter abase of constructor of type HomeController
1) Request for HomeController
Suggestions:
1) Ensure that you have defined a binding for HttpContextBase only once.
如果我删除绑定,那么它似乎做了我想要的(解析为 HttpContextWrapper),但我想知道它是如何注册的?