I would suggest the following to make this work in your application with both MVC and WebApi.
First your project will need to have references to the following
- Autofac
- Autofac.WebApi
- Autofac.Mvc5 (change the number at the end to match your aspnet mvc version)
Then in your Autofac registration you would need the following which will Register both MVC and WebApi Controllers and any other registrations you require. Then attach the Container to both the MVC DI and the WebApi DI.
var builder= new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly()); //Register MVC Controllers
builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); //Register WebApi Controllers
//Register any other components required by your code....
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); //Set the MVC DependencyResolver
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver((IContainer)container); //Set the WebApi DependencyResolver
I hope this helps.