3 回答
TA贡献1895条经验 获得超3个赞
问题出在“_LoginPartial.cshtml”中
删除这个
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
添加这个
@using Microsoft.AspNetCore.Identity
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
TA贡献2012条经验 获得超12个赞
在 dotnet core 2.1 中,我遇到了同样的问题,以下步骤解决了我的问题
1 ) 扩展 IdentityUser 或 IdentityRole
public class ApplicationUser : IdentityUser<Guid>
{
public DateTime JoinTime { get; set; } = DateTime.Now;
public DateTime DOB { get; set; } = Convert.ToDateTime("01-Jan-1900");
}
public class ApplicationRole : IdentityRole<Guid>
{
public string Description { get; set; }
}
2)更新ApplicationDbContext类
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
}
3) 更新 Stratup.cs 配置服务
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddScoped<IUserClaimsPrincipalFactory<ApplicationUser>, AppClaimsPrincipalFactory>();
services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, ApplicationRole>().AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();
}
更新 _LoginPartial.cshtml(共享 --> 查看)
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
TA贡献1802条经验 获得超10个赞
核心2有同样的问题。
你需要检查一个更大的面积是在文件_ManageNav.cshtml有你有更新的订单@inject SignInManager<IdentityUser> SignInManager
有@inject SignInManager<YOURCUSTOMMODEL> SignInManager
。
希望有帮助
- 3 回答
- 0 关注
- 187 浏览
添加回答
举报