I try to integrate autofac for webapi and I am having problem to make it work. My controller constructor signature is:
public class AController: ApiController
{
public AController(IComponentContext componentContext)
{}
}
In my global.asax file i have called the following code in Application_Start
protected void Application_Start()
{
var builder = new ContainerBuilder();
builder.RegisterApiControllers();
container = builder.Build();
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
}
When I try to run my application and to access my ressource "/api/A", the server returns an error 500 complaining about the fact the controller does not have a default constructor. I though that was the task of the AutofacWebApiDependencyResolver to inject the container in my case. How can I fix my issue ?
Thanks,