Skip to content

Instantly share code, notes, and snippets.

@chandermani
Created December 2, 2012 07:44
Show Gist options
  • Save chandermani/4187627 to your computer and use it in GitHub Desktop.
Save chandermani/4187627 to your computer and use it in GitHub Desktop.
Autofac integration ASP.Net MVC, WebAPI
private void RegisterIOC()
{
var builder = new ContainerBuilder();
builder.RegisterControllers(typeof(MvcApplication).Assembly);
builder.RegisterApiControllers(typeof(MvcApplication).Assembly);
AutofacBootstrap.Init(builder);
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new Autofac.Integration.WebApi.AutofacWebApiDependencyResolver(container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment