【发布时间】:2014-10-23 21:49:22
【问题描述】:
我正在尝试理解 vNext。
我编写了自定义 UserStore,它与 MongoDB 一起使用并实现了这些接口:
public class UserStore : IUserStore<ApplicationUser>, IUserPasswordStore<ApplicationUser>, IUserSecurityStampStore<ApplicationUser>,
IUserLoginStore<ApplicationUser>, IUserClaimStore<ApplicationUser>, IUserEmailStore<ApplicationUser>, IUserRoleStore<ApplicationUser>,
IUserTwoFactorStore<ApplicationUser>
在 Startup.cs 添加:
app.UseServices(services =>
{
services.AddIdentity<ApplicationUser>()
.AddUserStore(() => { return new UserStore(); })
.AddUserManager<UserManager<ApplicationUser>>()
.AddHttpSignIn();
services.AddMvc();
});
然后尝试使用 Visual Studio 模板中未更改的 AccountController 并遇到问题。
登录时,我在 UserStore.FindByNameAsync() 中收到 ObjectDisposedException - 称为 UserStore.Dispose()。
在 github.com/aspnet Store.Dispose() 上的 UserManager 代码中,仅在 UserManager.Dispose() 中调用。
我可以忽略 Dispose 的调用,一切正常,但这不是好方法。
所以我不知道我该怎么办
附:问题是:什么(以及为什么)可以调用 UserStore.Dispose()?
【问题讨论】:
标签: asp.net-mvc asp.net-identity asp.net-core objectdisposedexception asp.net-identity-3