private void RegisterIOC() { var builder = new ContainerBuilder(); builder.RegisterControllers(typeof(MvcApplication).Assembly); AutofacBootstrap.Init(builder); var container = builder.Build(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }
public void Configuration(IAppBuilder app) { var containerBuilder = new ContainerBuilder(); containerBuilder.RegisterApiControllers(Assembly.GetExecutingAssembly()); containerBuilder.RegisterWebApiFilterProvider(GlobalConfiguration.Configuration); AutofacBootstrap.Init(containerBuilder); var container = containerBuilder.Build(); WebApiConfig.Register(GlobalConfiguration.Configuration); var webApiResolver = new AutofacWebApiDependencyResolver(container); app.UseCors(CorsOptions.AllowAll); GlobalConfiguration.Configuration.DependencyResolver = webApiResolver; GlobalConfiguration.Configuration.EnsureInitialized(); }