我正在使用新的ASP.NET MVC 5身份验证框架进行身份验证.传统上我使用StructureMap进行依赖注入,但是我在连接新的AccountController时遇到了问题.
我的AccountController构造函数如下所示:
public AccountController() : this(new UserManager<OmpUser>(new UserStore<OmpUser>(new OmpDbContext()))) { } public AccountController(UserManager<OmpUser> userManager) { UserManager = userManager; }
我的StructureMap配置如下所示:
public static class IoC { public static IContainer Initialize() { ObjectFactory.Initialize(x => { x.Scan(scan => { scan.TheCallingAssembly(); scan.WithDefaultConventions(); }); //x.Register<IUserStore<OmpUser>>(() => // new UserStore<OmpUser>(new OmpDbContext())); x.For<OMPEntities>().HttpContextScoped(); }); return ObjectFactory.Container; } }
当我运行该项目我得到以下错误:
Activation error occured while trying to get instance of type
AccountController,key “”
任何关于如何新建UserManager对象进行构建注入的想法?我试过搜索,但在那里找不到太多的指导.