title: ASP.NET Core 2 No authentication handler is configured to handle the scheme
body: <p>I want to provide authorization in an ASP.NET Core 2 application. 
  After sending the model with the data in Account/Login, after the call to <code>await Authenticate(user)</code>, I get an error message.
  I can not understand where there is a lack of description.</p>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>//ConfigureServices
  services.AddAuthentication(options =&gt;
  {
      options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
      options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
  }).AddCookie("TmiginScheme", options =&gt;
  {
      options.LoginPath = "/Account/Login";
      options.LogoutPath = "/Account/Logout";
      options.ExpireTimeSpan = TimeSpan.FromHours(1);
      options.SlidingExpiration = true;
  });
  
  //Configure
  app.UseAuthentication();
  </code></pre>
  
  <p><strong>AccountController</strong></p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public async Task&lt;IActionResult&gt; Login(LoginModel model)
  {
      if (ModelState.IsValid)
      {
          User user = null;
          Cryptex cryptex = new Cryptex();
          string password = cryptex.EncryptText(model.Password, "TMigin");
  
          // Ищем user
          user = fStorage.Users.GetUserByLogin(model.Login);
          if (user != null)
          {
              if (string.Compare(user.Password, password) != 0)
              {
                  user = null;
              }
          }
  
          if (user != null)
          {
              await Authenticate(user);
              return RedirectToAction("Index", "CMS");
          }
  
          else
          {
              // Логируем ошибку входа
              ModelState.AddModelError("", "Ошибка входа");
          }
      }
  
      return View(model);
  }
  
  private async Task Authenticate(User user)
  {
      var claims = new List&lt;Claim&gt;
      {
          new Claim(ClaimsIdentity.DefaultNameClaimType, user.Name),
          new Claim("CMS", "True")
      };
      var identity = new ClaimsIdentity(claims);
      var principal = new ClaimsPrincipal(identity);
      await HttpContext.Authentication.SignInAsync("TmiginScheme", principal);
  }
  </code></pre>
  
  <p><strong>fixed</strong></p>
  
  <p>Not working, as I placed the code after the <code>app.UseMvc(...){}</code>.
  In the screenshot the correct location.</p>
  
  <p><a href="https://i.stack.imgur.com/TBzj1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TBzj1.png" alt="correctly"></a></p>