【发布时间】:2022-01-21 20:09:04
【问题描述】:
我使用 ASP.NET Core MVC 5.0 开发了我的第一个应用程序。
已经存在一个数据库,但我在新程序中实现了完整的数据库,现在问题是 ASP.NET Core 身份。所以对于身份,我按照说明搭建了脚手架,最后使用email和pass实现了默认的身份认证。
services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
在startup.cs 中,然后我有一个具有现有字段的模型,即 cardno、phone 并希望对此进行身份验证。在 PHP 中,使用 $_SESSION 变量真的很容易。但现在在这里我希望这发生在 ASP.NET 中,任何帮助将不胜感激。
services.AddIdentity<CnicUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>();
我为自定义身份验证添加的此代码出现此错误
应用程序启动异常 System.InvalidOperationException:方案已存在:Identity.Application 在 Microsoft.AspNetCore.Authentication.AuthenticationOptions.AddScheme(字符串 name, Action`1 configureBuilder)
【问题讨论】:
标签: c# asp.net sql-server asp.net-core asp.net-identity