public static void Run() { // Configure Autofac AutofacWebapiConfig.Initialize(GlobalConfiguration.Configuration); //Configure AutoMapper MapperRegistration.RegisterMapperConfiguration(); }
public IContainer ConfigureAutofac(HttpConfiguration config, IAppBuilder app) { _container = AutofacWebapiConfig.Initialize(config); // Register the Autofac middleware FIRST. This also adds // Autofac-injected middleware registered with the container. app.UseAutofacMiddleware(_container); // http://stackoverflow.com/questions/37826551/authorization-with-asp-net-identity-autofac-owin-integration // https://github.com/autofac/Autofac.WebApi.Owin/issues/3 // Configure Auth ConfigureOAuth(config, app); // To enable the lifetime scope created during the OWIN request to extend into the Web API dependency scope app.UseAutofacWebApi(config); app.UseWebApi(config); return(_container); }