我正在使用 ASP.Net MVC core 2.1 开发一个应用程序,其中不断出现以下异常。
“InvalidOperationException:没有为方案‘CookieSettings’注册身份验证处理程序。注册的方案是:Identity.Application、Identity.External、Identity.TwoFactorRememberMe、Identity.TwoFactorUserId。您是否忘记调用 AddAuthentication().AddSomeAuthHandler?”
我浏览了文章并做了必要的更改,但例外情况仍然相同。我不知道下一步该做什么。
以下是我的startup.cs:
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<Infrastructure.Data.ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection"))); …Run Code Online (Sandbox Code Playgroud) c# ×1