I'm trying to understand vNext.
I wrote custom UserStore, that works with MongoDB and implements these interfaces:
public class UserStore : IUserStore<ApplicationUser>, IUserPasswordStore<ApplicationUser>, IUserSecurityStampStore<ApplicationUser>,
IUserLoginStore<ApplicationUser>, IUserClaimStore<ApplicationUser>, IUserEmailStore<ApplicationUser>, IUserRoleStore<ApplicationUser>,
IUserTwoFactorStore<ApplicationUser>
In Startup.cs added:
app.UseServices(services =>
{
services.AddIdentity<ApplicationUser>()
.AddUserStore(() => { return new UserStore(); })
.AddUserManager<UserManager<ApplicationUser>>()
.AddHttpSignIn();
services.AddMvc();
});
Then tried to use unchanged AccountController from Visual Studio template and have troubles.
When signing in i getting ObjectDisposedException in UserStore.FindByNameAsync() -- something called UserStore.Dispose().
In UserManager code on github.com/aspnet Store.Dispose() called only in UserManager.Dispose().
I can just ignore calls of Dispose and all works fine, but this is not good way.
So i have no ideas what shall i do
P.S. The Question is: what (and why) can call UserStore.Dispose()?
In vNext, DI is built in and manages the lifetime of the identity services. You are probably trying to use identity after the services have been disposed, by default identity services have lifetimes scoped to a request, so if for example, you are trying to hang onto a reference to a user manager and reuse it across multiple requests, that would cause the ObjectDisposedException.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With