title: .NET Core 2.0 Authorization filter causes an internal error
body: <p>An authorization filter will cause an internal error on a .NET Core 2.0 web application. Steps to reproduce the problem are very simple: create a new .NET Core 2.0 MVC project with "no authentication", put an authorization filter on a controller method, access the corresponding URL and a "500 Internal Server Error" will be returned.</p>
  
  <pre><code>[Authorize]
  public IActionResult Contact()
  {
      ViewData["Message"] = "Your contact page.";
  
      return View();
  }
  </code></pre>
  
  <p>A similar code in .NET Core 1.1 will correctly return the response "401 Unauthorized".</p>
  
  <p>I had a posted a similar question on the problem: <a href="https://stackoverflow.com/questions/48073548/custom-cookie-authentication-not-working-after-migration-from-asp-net-core-1-1-m">Custom cookie authentication not working after migration from ASP.NET Core 1.1 MVC to 2.0</a> while I still hadn't understood that the problem is much wider than it was in my specific case.</p>
  
  <p>The exception:</p>
  
  <pre><code>System.InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
     at Microsoft.AspNetCore.Authentication.AuthenticationService.&lt;ChallengeAsync&gt;d__11.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Mvc.ChallengeResult.&lt;ExecuteResultAsync&gt;d__14.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.&lt;InvokeResultAsync&gt;d__19.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.&lt;InvokeFilterPipelineAsync&gt;d__17.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.&lt;InvokeAsync&gt;d__15.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Builder.RouterMiddleware.&lt;Invoke&gt;d__4.MoveNext()
  --- End of stack trace from previous location where exception was thrown ---
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
     at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.&lt;Invoke&gt;d__7.MoveNext()
  </code></pre>