public void Configuration(IAppBuilder app) { IContainer container = RegisterServices(); HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute("DefaultHttpRoute", "api/{controller}"); AutofacOwinDependencyResolver resolver = new AutofacOwinDependencyResolver(container); app.UseDependencyResolver(resolver) .Use<RandomTextMiddleware>() .UseWebApiWithOwinDependencyResolver(resolver, config); }
public static IAppBuilder UseAutofacDependencyResolver(this IAppBuilder app, IContainer container) { AutofacOwinDependencyResolver resolver = new AutofacOwinDependencyResolver(container); return app.UseDependencyResolver(resolver); }