I am using AutoFac to registered api controller but don't know whats the problem
Getting error
Type 'myApp.WebAPI.Controllers.myController' does not have a default constructor
I added IocHelper class as below
public class IocHelper {
public static IContainer CreateContainer() {
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
return container;
}
}
Thanks in advance.