If I check the code, the only difference is that AspNetUserManager<TUser>
gets the (default) cancelationtoken from the httpcontext (on request aborted). I guess that gives a better experience when canceling the request. All other methods and properties are inherited from the UserManager<TUser>
/// <summary>
/// Provides the APIs for managing user in a persistence store.
/// </summary>
/// <typeparam name="TUser">The type encapsulating a user.</typeparam>
public class AspNetUserManager<TUser> : UserManager<TUser>, IDisposable where TUser : class
{
private readonly CancellationToken _cancel;
/// <summary>
/// Constructs a new instance of <see cref="AspNetUserManager{TUser}"/>.
/// </summary>
/// <param name="store">The persistence store the manager will operate over.</param>
/// <param name="optionsAccessor">The accessor used to access the <see cref="IdentityOptions"/>.</param>
/// <param name="passwordHasher">The password hashing implementation to use when saving passwords.</param>
/// <param name="userValidators">A collection of <see cref="IUserValidator{TUser}"/> to validate users against.</param>
/// <param name="passwordValidators">A collection of <see cref="IPasswordValidator{TUser}"/> to validate passwords against.</param>
/// <param name="keyNormalizer">The <see cref="ILookupNormalizer"/> to use when generating index keys for users.</param>
/// <param name="errors">The <see cref="IdentityErrorDescriber"/> used to provider error messages.</param>
/// <param name="services">The <see cref="IServiceProvider"/> used to resolve services.</param>
/// <param name="logger">The logger used to log messages, warnings and errors.</param>
public AspNetUserManager(IUserStore<TUser> store,
IOptions<IdentityOptions> optionsAccessor,
IPasswordHasher<TUser> passwordHasher,
IEnumerable<IUserValidator<TUser>> userValidators,
IEnumerable<IPasswordValidator<TUser>> passwordValidators,
ILookupNormalizer keyNormalizer,
IdentityErrorDescriber errors,
IServiceProvider services,
ILogger<UserManager<TUser>> logger)
: base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
{
_cancel = services?.GetService<IHttpContextAccessor>()?.HttpContext?.RequestAborted ?? CancellationToken.None;
}
/// <summary>
/// The cancellation token associated with the current HttpContext.RequestAborted or CancellationToken.None if unavailable.
/// </summary>
protected override CancellationToken CancellationToken => _cancel;
}
From https://github.com/dotnet/aspnetcore/blob/main/src/Identity/Core/src/AspNetUserManager.c
Very related, there is a suggestion to get rid of this class:
Consider adding optional cancellationToken to manager APIs
If we do this in 3.0, we could probably also get rid of the automatic HttpRequest.Aborted hookup, which would let us get rid of the derived AspNetUserManager entirely.
See https://github.com/dotnet/aspnetcore/issues/5763
UserManager<TUser>
is Derived fromAspNetUserManager<TUser>
: InheritanceObject --> UserManager<TUser> --> AspNetUserManager<TUser>
– Sayyid