title: Exception when OWIN Middleware AuthenticationHandler AuthenticateCoreAsync returns null
body: <p>I am try to write a custom Owin Authentication Middleware. I am currently only writing a dummy one even simpler than <a href="http://coding.abel.nu/2014/06/writing-an-owin-authentication-middleware/" rel="nofollow">this</a>.</p>
  
  <p>According to <a href="http://brockallen.com/2013/08/07/owin-authentication-middleware-architecture/" rel="nofollow">this</a> and other tutorials, it seems I could return null in <strong>AuthenticateCoreAsync</strong> of my DummyAuthenticationHandler to indicate authentication failure. So I did</p>
  
  <pre><code>protected override Task&lt;AuthenticationTicket&gt; AuthenticateCoreAsync()
  {
      return null;
  }
  </code></pre>
  
  <p>It is ok if I return a new AuthenticationTicket with some dummy ClaimsIdentity in it, <strong>but when I return null I got this exception when I call any controller</strong>.</p>
  
  <pre><code>[NullReferenceException: Object reference not set to an instance of an object.]
  Microsoft.Owin.Security.Infrastructure.&lt;BaseInitializeAsync&gt;d__0.MoveNext() +450
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
  Microsoft.Owin.Security.Infrastructure.&lt;Invoke&gt;d__0.MoveNext() +264
  System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
  Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.&lt;RunApp&gt;d__5.MoveNext() +191
  ....
  </code></pre>
  
  <p>I have been using Web Api 2 with Ninject but it seems even I tried commenting out Niject stuff in Startup it still won't work. and all my dependency are up to date. This is my Startup.</p>
  
  <pre><code>{
      HttpConfiguration configuration = new HttpConfiguration();
  
      application.UseDummyAuthentication();
      configuration.SuppressDefaultHostAuthentication();
      configuration.Filters.Add(new HostAuthenticationFilter("dummy"));
      WebApiConfig.Register(configuration);
      application.UseNinjectMiddleware(() =&gt;
      {
          return NinjectWebCommon.CreateKernel(WebApiConfig.CreateConfigurationDelegate());
      });
      application.UseNinjectWebApi(configuration);
  }
  </code></pre>
  
  <p>I have been scratching my head for a day, really would like to have some help.</p>