I just updated all my Autofac packages to the latest version to get web api 2 support. In my api controller I created a constructor requesting an instance of a service level class, this is identical to the way I use autofac with all my mvc controllers and everything works fine .
In my ioc configuration that runs when the application starts, I registered the web api controller.
builder.RegisterType<UsersApiController>().InstancePerApiRequest();
I also tried
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
But autofac does not work with my api controller, the constructor that asks for a class of service is not even executed. I also get an error if I do not include a less default constructor in the api controller.
Is there a known issue with web api 2 and auto fac, or am I missing something?
source
share