title: Action Filter is not working in asp.net core Web API
body: <p>I have created an action filter for HTTP request validation in ASP.NET Core 3.1 Web API.</p>
  <p>Unfortunately it is not working. The problem has to be at controller level, because the same works in .NET Framework.</p>
  <p><strong>CustomAuthorize.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public class CustomAuthorize : ActionFilterAttribute
  {
      private readonly IConfiguration _configuration;
  
      public CustomAuthorize(IConfiguration configuration)
      {
          _configuration = configuration;
      }
  
      public override void OnActionExecuting(HttpActionContext context)
      {
          string secrect = _configuration.GetSection(&quot;AuthJWT&quot;).GetSection(&quot;Secrect&quot;).Value;
          var request = context.Request.Headers.GetValues(&quot;AuthJWT&quot;).FirstOrDefault();
          //Add Validation code here
          base.OnActionExecuting(context);
  
      }
  }
  </code></pre>
  <p><strong>HomeController</strong></p>
  <pre><code>[Route(&quot;[controller]&quot;)]
  [ApiController]
  [ServiceFilter(typeof(CustomAuthorize))]
  public class HomeController : ControllerBase
  {       
      [HttpGet(&quot;getdata&quot;)]
      public IActionResult GetData()
      {
          return Ok(&quot;Success&quot;);
      }
  }
  </code></pre>
  <p><strong>Startup.cs</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
      public IConfiguration Configuration { get; }
  
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddCors();
  
          services.AddControllers();
  
          services.AddScoped&lt;CustomAuthorize&gt;();
  
      }
  
      public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
  
          app.UseRouting();
  
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapControllers();
          });
      }
  }
  </code></pre>