对于'Microsoft.AspNetCore.Identity.SignInManager类型不提供服务,时间>>

问题描述 投票:17回答:2

我正在

InvalidOperationException:类型无服务'Microsoft.AspNetCore.Identity.SignInManager1 [Authorization.IdentityModels.ApplicationUser]'已注册。

当我运行ApsCore MVC网站时。

这是我的代码中的片段:

ConfigureServices:

services.AddDbContext<ApplicationDbContext>(options =>
                        options.UseNpgsql(configuration["Data:DefaultConnection:ConnectionString"]));



services.AddIdentity<ApplicationUser, IdentityRole<Guid>>()
                    .AddEntityFrameworkStores<ApplicationDbContext, Guid>()
                    .AddDefaultTokenProviders();

配置:

app.UseIdentity();

ApplicationDbContext.cs

public class ApplicationDbContext : IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid> 

ApplicationUser.cs

 public class ApplicationUser : IdentityUser<Guid>

如果您能帮助我,我将非常高兴。

我正在收到InvalidOperationException:类型'Microsoft.AspNetCore.Identity.SignInManager 1 [Authorization.IdentityModels.ApplicationUser]的服务尚未注册。当我运行我的...

asp.net-core asp.net-identity identity .net-core
2个回答
27
投票

在将我的Identity类移动到Guid并找到解决方案here后,遇到相同的问题:


15
投票

不确定您是否仍然会看到此问题,但是对于其他偶然发现的问题,这里有一些帮助。 (请注意,具体信息是针对版本1的,但是对注入的依赖项不可用的需求是相同的。)

© www.soinside.com 2019 - 2024. All rights reserved.