title: InvalidOperationException: No authentication handler is registered for the scheme 'CookieSettings'
body: <p>I am developing an application using ASP.Net MVC core 2.1 where I am continuously getting the following exception.</p>
  <blockquote>
  <p>InvalidOperationException: No authentication handler is registered for the scheme 'CookieSettings'. The registered schemes are: Identity.Application, Identity.External, Identity.TwoFactorRememberMe, Identity.TwoFactorUserId. Did you forget to call AddAuthentication().AddSomeAuthHandler?&quot;</p>
  </blockquote>
  <p>I went through articles, did the necessary changes, but the exception remains the same. I am unable to figure out what to do next.</p>
  <p>following is my startup.cs :</p>
  <pre><code>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&lt;CookiePolicyOptions&gt;(options =&gt;
          {
              // This lambda determines whether user consent for non-essential cookies is needed for a given request.
              options.CheckConsentNeeded = context =&gt; true;
              options.MinimumSameSitePolicy = SameSiteMode.None;
          });
  
          services.AddDbContext&lt;Infrastructure.Data.ApplicationDbContext&gt;(options =&gt;
              options.UseSqlServer(
                  Configuration.GetConnectionString(&quot;DefaultConnection&quot;)));
  
          services.AddDefaultIdentity&lt;IdentityUser&gt;()
              .AddEntityFrameworkStores&lt;Infrastructure.Data.ApplicationDbContext&gt;();
  
          services.AddSingleton(Configuration);
  
          //Add application services.
         services.AddTransient&lt;IEmailSender, AuthMessageSender&gt;();
          services.AddTransient&lt;ISmsSender, AuthMessageSender&gt;();
          //Add services
          services.AddTransient&lt;IContactManagement, ContactManagement&gt;();
          services.AddTransient&lt;IRepository&lt;Contact&gt;, Repository&lt;Contact&gt;&gt;();
          services.AddTransient&lt;IJobManagement, JobJobManagement&gt;();
          services.AddTransient&lt;IRepository&lt;Job&gt;, Repository&lt;Job&gt;&gt;();
          services.AddTransient&lt;IUnitManagement, UnitManagement&gt;();
          services.AddTransient&lt;IRepository&lt;Sensor&gt;, Repository&lt;Sensor&gt;&gt;();
          services.AddTransient&lt;IJobContactManagement, JobContactManagement&gt;();
          services.AddTransient&lt;IRepository&lt;JobContact&gt;, Repository&lt;JobContact&gt;&gt;();
          services.AddTransient&lt;IJobContactEventManagement, JobContactEventManagement&gt;();
          services.AddTransient&lt;IRepository&lt;JobContactEvent&gt;, Repository&lt;JobContactEvent&gt;&gt;();
          services.AddTransient&lt;IJobsensorManagement, JobsensorManagement&gt;();
          services.AddTransient&lt;IRepository&lt;JobSensor&gt;, Repository&lt;JobSensor&gt;&gt;();
          services.AddTransient&lt;IEventTypesManagement, EventTypesManagement&gt;();
          services.AddTransient&lt;IRepository&lt;EventType&gt;, Repository&lt;EventType&gt;&gt;();
          services.AddTransient&lt;IJobSensorLocationPlannedManagement, JobSensorLocationPlannedManagement&gt;();
          services.AddTransient&lt;IRepository&lt;JobSensorLocationPlanned&gt;, Repository&lt;JobSensorLocationPlanned&gt;&gt;();
          services.AddTransient&lt;IDataTypeManagement, DataTypeManagement&gt;();
          services.AddTransient&lt;IRepository&lt;DataType&gt;, Repository&lt;DataType&gt;&gt;();
          services.AddTransient&lt;IThresholdManegement, ThresholdManegement&gt;();
          services.AddTransient&lt;IRepository&lt;Threshold&gt;, Repository&lt;Threshold&gt;&gt;();
          services.AddTransient&lt;ISeverityTypeManagement, SeverityTypeManagement&gt;();
          services.AddTransient&lt;IRepository&lt;SeverityType&gt;, Repository&lt;SeverityType&gt;&gt;();
          services.AddTransient&lt;ISensorDataManagement, SensorDataManagement&gt;();
          services.AddTransient&lt;IRepository&lt;SensorData&gt;, Repository&lt;SensorData&gt;&gt;();
          services.AddTransient&lt;ISensorLocationManagement, SensorLocationManagement&gt;();
          services.AddTransient&lt;IRepository&lt;SensorLocation&gt;, Repository&lt;SensorLocation&gt;&gt;();
  
          services.AddTransient&lt;ISensorStatusTypeManagement, SensorStatusTypeManagement&gt;();
          services.AddTransient&lt;IRepository&lt;SensorStatusType&gt;, Repository&lt;SensorStatusType&gt;&gt;();
          services.AddTransient&lt;IRepository&lt;SensorDataToday&gt;, Repository&lt;SensorDataToday&gt;&gt;();
          services.AddTransient&lt;ISensorDataTodayManagement, SensorDataTodayManagement&gt;();
  
          services.AddSession();
  
  
          services.AddSession(options =&gt;
          {
              options.IdleTimeout = TimeSpan.FromMinutes(20);
          });
  
          services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                 .AddCookie(options =&gt;
                 {
                     options.LoginPath = &quot;/Account/Login/&quot;;
                     options.LogoutPath = &quot;/Account/Logout/&quot;;
                 });
  
          services.AddAuthentication(options =&gt;
          {
              options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
          });
  
  
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseDatabaseErrorPage();
          }
          else
          {
              app.UseExceptionHandler(&quot;/Home/Error&quot;);
              app.UseHsts();
          }
  
          app.UseHttpsRedirection();
          app.UseStaticFiles();
          app.UseCookiePolicy();
  
          app.UseAuthentication();
  
          app.UseMvc(routes =&gt;
          {
              routes.MapRoute(
                  name: &quot;default&quot;,
                  template: &quot;{controller=Home}/{action=Index}/{id?}&quot;);
          });
      }
  </code></pre>
  <p>Also I wanted to know if there are any changes required in AccountController?</p>