小编Dan*_*ani的帖子

没有类型'Microsoft.AspNetCore.Identity.SignInManager的服务时

我正进入(状态

InvalidOperationException:没有注册类型'Microsoft.AspNetCore.Identity.SignInManager 1 [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();
Run Code Online (Sandbox Code Playgroud)

配置:

app.UseIdentity();
Run Code Online (Sandbox Code Playgroud)

ApplicationDbContext.cs

public class ApplicationDbContext : IdentityDbContext<ApplicationUser, IdentityRole<Guid>, Guid> 
Run Code Online (Sandbox Code Playgroud)

ApplicationUser.cs

 public class ApplicationUser : IdentityUser<Guid>
Run Code Online (Sandbox Code Playgroud)

如果你能帮助我,我会很高兴的.

identity asp.net-identity .net-core asp.net-core

17
推荐指数
2
解决办法
2万
查看次数