title: ASP.Net Core WebAPI - No 'Access-Control-Allow-Origin' header is present on the requested resource
body: <p>I'm encountering an issue with CORS while using <strong><code>IAsyncResourceFilter</code></strong> implementation.
  I want to be able to call my actions from other domains as well...</p>
  
  <p>I've defined the CORS policy under my <code>Startup</code> file as the following:</p>
  
  <pre><code>services.AddCors(options =&gt;
  {
      options.AddPolicy("AllowAllOrigins",
      builder =&gt;
      {
          builder.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin();
      });
  });
  </code></pre>
  
  <p>And under the <code>Configure</code> method:</p>
  
  <pre><code>app.UseCors("AllowAllOrigins");
  </code></pre>
  
  <p>It works fine without using a <strong><code>TypeFilterAttribute</code></strong> which use <strong><code>IAsyncResourceFilter</code></strong>.</p>
  
  <p>For example calling my API action without any <code>TypeFilterAttribute</code> attribute works:</p>
  
  <pre><code>public bool Get()
  {
      return true;
  }
  </code></pre>
  
  <p>But when adding my <code>TypeFilterAttribute</code> as follows it doesn't work and returns the error about the CORS:</p>
  
  <pre><code>[MyTypeFilterAttribute("test")]
  public bool Get()
  {
      return true;
  }
  </code></pre>
  
  <p>Anything I'm missing? What should I add when using <code>IAsyncResourceFilter</code>?</p>
  
  <p>The following is the <code>MyTypeFilterAttribute</code> code: (With no real logic...)</p>
  
  <pre><code>public class MyTypeFilterAttribute : TypeFilterAttribute
  {
      public MyTypeFilterAttribute(params string[] name) : base(typeof(MyTypeFilterAttributeImpl))
      {
          Arguments = new[] { new MyTypeRequirement(name) };
      }
  
      private class MyTypeFilterAttributeImpl: Attribute, IAsyncResourceFilter
      {
          private readonly MyTypeRequirement_myTypeRequirement;
  
          public MyTypeFilterAttributeImpl(MyTypeRequirement myTypeRequirement)
          {
              _myTypeRequirement= myTypeRequirement;
          }
  
          public async Task OnResourceExecutionAsync(ResourceExecutingContext context, ResourceExecutionDelegate next)
          {
              context.Result = new OkResult();
  
              await next();
          }
      }
  }
  
  public class MyTypeRequirement : IAuthorizationRequirement
  {
      public string Name { get; }
  
      public MyTypeRequirement(string name)
      {
          Name = name;
      }
  }
  </code></pre>