title: NTLM authentication on specific route in ASP.NET Core
body: <p>Trying to implement subject in a test environment.</p>
  
  <pre class="lang-cs prettyprint-override"><code>.UseWebListener(options=&gt;
  {
      options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.NTLM |
                                                        AuthenticationSchemes.Negotiate;
      options.ListenerSettings.Authentication.AllowAnonymous = true;
  })
  </code></pre>
  
  <p>And</p>
  
  <pre class="lang-cs prettyprint-override"><code>app.UseWhen(context =&gt; context.Request.Path.StartsWithSegments("/ntlm"),
              builder =&gt; builder.UseCookieAuthentication(new CookieAuthenticationOptions()
              {
                  AutomaticAuthenticate = true,
                  AutomaticChallenge = true,
                  LoginPath = "/Main/Login",
                  LogoutPath = "/Main/Logout",
                  AuthenticationScheme = "NTLM", AccessDeniedPath = "/Main/Deny"
              }
              ));
  
  app.UseWhen(context =&gt; !context.Request.Path.StartsWithSegments("/ntlm"),
              builder =&gt; builder.UseCookieAuthentication(new CookieAuthenticationOptions()
              {
                  AutomaticAuthenticate = false,
                  AutomaticChallenge = false,
                  LoginPath = "/Main/Login",
                  LogoutPath = "/Main/Logout",
                  AuthenticationScheme = "Cookies"
              }
              ));
  </code></pre>
  
  <p>But it seems there`s no difference, whether request path starts with "/ntlm" or not.</p>
  
  <p>I tried running two WebListeners, but I think there`s much more overhead.</p>
  
  <p>What I want to achieve:
  User gets on start page with login form and there`s a "Windows auth" button on it.
  He can enter credentials or press the button and go in with his OS identity.</p>