我的服务中有以下代码,应该创建UserManager实例
public class SubscriptionService : ISubscriptionService
{
private UserManager<ApplicationUser> userManager;
public UserManager<ApplicationUser> UserManager
{
get
{
return userManager;
}
private set { userManager = value; }
}
public SubscriptionService(
UserManager<ApplicationUser> userManager,
StripeCustomerService customerService,
StripeSubscriptionService subscriptionService)
{
this.userManager = userManager;
this.customerService = customerService;
this.subscriptionService = subscriptionService;
}
public SubscriptionService(UserManager<ApplicationUser> userManager)
{
this.userManager = userManager;
}
当第一次在课堂内调用userManager时,它可以正常工作,但第二次调用会返回错误“cannot access a disposed object UserManager
”
我在控制器中使用SubscriptionService类:
public ISubscriptionService SubscriptionService
{
get
{
return subscriptionService ?? new SubscriptionService(_userManager);
}
private set
{
subscriptionService = value;
}
}
有人能指出我错在哪里以及如何解决这个问题吗?
我正在使用ASP.NET Core 1.0
编辑:这是在首次执行函数
后立即检查的用户管理器