在从inDependencyResolver.GetService()
调用的方法中使用时,我遇到了一个问题。UserManager.CreateAsync()
AspNet.Identity
根据本文,我已向 AspNetUser 添加了一个 UserProfile 类 。
一切正常,但是在创建新用户时,它也会尝试创建我的 UserProfile 实体,并且在其中我有一个属性[CheckIfExists]
检查 UserProfile 是否已经存在。在这个方法中,我们称之为它CheckIfExists()
,我用来DependencyResolver.GetService()
将我的接口解析ICheckIfExists
为“concreate”类CheckIfExists
。这失败了,因为当前线程不是 HttpContext 的一部分(因为它在 CreateAsync():s 线程中运行)。
有没有人遇到过这个问题?有解决办法吗?我正在为 IoC 使用 StructureMap。