title: ASP.NET disable authorization depending on host
body: <p>I have an ASP.NET Core application and I have decorated my constroller/actions with Authorize attribute. In Startup.cs, I have defined the authentication like this:</p>
  
  <pre><code>services.AddAuthentication(Microsoft.AspNetCore.Server.IISIntegration.IISDefaults.AuthenticationScheme);
  </code></pre>
  
  <p>When I run my application in IIS or IIS Express, authorization works. However, I want to disable authorization when running in hosts that don't support Windows authentication like Console application.</p>
  
  <p>I was thinking of doing this:</p>
  
  <pre><code>services.AddMvc(options =&gt;
  {
       if (!isWindowsAuthenticationSupported)
          options.Filters.Add(new AllowAnonymousFilter());
  });
  </code></pre>
  
  <p>If this is the right approach, how would I set the isWindowsAuthenticationSupported variable?</p>