I have .net identity setup in my startup:
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
And this works fine in the controller with constructor injection.
However If I tell .net to inject another class, ie:
services.AddScoped<WebSocketEvent>();
and then in the class:
public class WebSocketEvent
{
IHubContext<SignalHub> _hubcontext;
UserManager<ApplicationUser> _userManager;
public WebSocketEvent(IHubContext<SignalHub> hubcontext, UserManager<ApplicationUser> userManager)
{
_hubcontext = hubcontext;
_userManager = userManager;
}
}
It cant make/inject the userManager and I get:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[WebSockets.Models.ApplicationUser]' while attempting to activate 'WebSockets.Services.WebSocketEvent'.