Last active
March 4, 2020 19:09
-
-
Save 3nth/5239a85d3e58511092a6 to your computer and use it in GitHub Desktop.
AutofacConfig for ASP.NET Identity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutofacConfig | |
{ | |
public static void Configure() | |
{ | |
var builder = new ContainerBuilder(); | |
builder.RegisterType<ApplicationDbContext>().AsSelf().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationUserStore>().As<IUserStore<PortalUser>>().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationUserManager>().AsSelf().InstancePerLifetimeScope(); | |
builder.RegisterType<ApplicationSignInManager>().AsSelf().InstancePerLifetimeScope(); | |
builder.Register<IAuthenticationManager>(c => HttpContext.Current.GetOwinContext().Authentication); | |
builder.RegisterModule(new AutofacWebTypesModule()); | |
builder.RegisterFilterProvider(); | |
builder.RegisterControllers(Assembly.GetExecutingAssembly()); | |
IContainer container = builder.Build(); | |
DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment