相关疑难解决方法(0)

如何将我的Autofac容器插入ASP.NET Identity 2.1

我一直在研究新版ASP.NET Identity 2.1的新功能,其中一项增强功能是集成到OWIN中间件中的新IoC功能.我在这些例子中看到的一句话是这一句:

app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
Run Code Online (Sandbox Code Playgroud)

这句话接收一个函数委托,它返回示例中提供的管理器实现的新实例:

 public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options,
        IOwinContext context)
    {
        var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>())); 
Run Code Online (Sandbox Code Playgroud)

我个人不喜欢这个实现,因为我无法使用容器为这些管理器注入任何我想要的依赖项.

还有一个"神奇地""IdentityFactoryOptions"和"IOwinContext"被"神奇地"注入到我无法进入我的IoC容器的函数中.

有没有人对此实施有更好的解决方法?

asp.net asp.net-mvc owin asp.net-identity

39
推荐指数
2
解决办法
1万
查看次数

标签 统计

asp.net ×1

asp.net-identity ×1

asp.net-mvc ×1

owin ×1