Autofac with MVC4: controller does not have a default constructor
With the RegisterApiControllers
method you tell Autofac where (in which assembly) it should look for your ApiControllers
So the following call:
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
Registers the ApiControllers
from the current assembly (project).
If you have ApiController
s also in a different project you need to use it like this:
builder.RegisterApiControllers(typeof(UserController).Assembly);
Which means: register all the ApiController
form the assembly (project) where the UserController
lives. So you only need one RegisterApiControllers
per assembly even if you have multiple ApiController
in an assembly (project).