Using Simple Injector in Web API and OWIN

前端 未结 1 1528
野趣味
野趣味 2020-12-15 08:32

I\'m experiencing the same problem as described here and my set up is almost identical to this that is actually based on this guide. When I access a method in my controller

相关标签:
1条回答
  • 2020-12-15 09:13

    I had the same issue but with UnityDependencyResolver. But I think it should also work for SimpleInjectorWebApiDependencyResolver. Try to register your resolver like this (as a Property of HttpConfiguration):

    public void Configuration(IAppBuilder app)
    {
        var container = GetContainer(); // Initialise container
    
        HttpConfiguration config = new HttpConfiguration
        {
            DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        };
    
        WebApiConfig.Register(config);
        app.UseWebApi(config);
    }
    
    0 讨论(0)
提交回复
热议问题