को सक्रिय करने का प्रयास करते समय 'Microsoft.AspNetCore.Identity.UserManager` टाइप करने के लिए सेवा को हल करने में असमर्थ। मुझे यह त्रुटि लॉग इन कंट्रोलर में मिल रही है।'AuthController'
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Automobile.Models.Account]' while attempting to activate 'Automobile.Server.Controllers.AuthController'.
यहाँ प्रमाणीकरण नियंत्रक निर्माता है:
private SignInManager<Automobile.Models.Account> _signManager;
private UserManager<Automobile.Models.Account> _userManager;
public AuthController(UserManager<Models.Account> userManager,
SignInManager<Automobile.Models.Account> signManager)
{
this._userManager = userManager;
this._signManager = signManager;
}
और यहाँ है startup.cs में ConfigureServices:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.Configure<AppConfig>(Configuration.GetSection("AppSettings"));
//var provider = HttpContext.ApplicationServices;
//var someService = provider.GetService(typeof(ISomeService));
services.AddDbContext<Providers.Database.EFProvider.DataContext>(options => options
.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly("Automobile.Server")
));
services.AddIdentity<IdentityUser, IdentityRole>(options =>
{
options.User.RequireUniqueEmail = false;
})
.AddEntityFrameworkStores<Providers.Database.EFProvider.DataContext>()
.AddDefaultTokenProviders();
//services.AddScoped<SignInManager<Automobile.Models.Account>, SignInManager<Automobile.Models.Account>>();
//services.AddScoped<UserManager<Automobile.Models.Account>, UserManager<Automobile.Models.Account>>();
services.AddMvc();
App.Service = services.BuildServiceProvider();
// Adds a default in-memory implementation of IDistributedCache.
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromSeconds(10);
options.CookieHttpOnly = true;
});
}
ऐसा लगता है कि आप 'पहचान उपयोगकर्ता' को मूल उपयोगकर्ता वर्ग के रूप में पंजीकृत कर रहे हैं लेकिन फिर आप 'ऑटोमोबाइल.मोडल्स.काउंट' का उपयोग कर रहे हैं, जो निश्चित रूप से एएसपी.NET पहचान –
@FedericoDipuma द्वारा पंजीकृत नहीं है बहुत :) हल हो गया। – OMID
आपने इसे कैसे हल किया ..? – Lobato