title: 405 (Method Not Allowed) and blocked by CORS policy
body: <p>I have Asp.Net Core(3) WebApi project with UI based on Angular(7.2.1) on Client side.
  When using Postman or just using the URL I can use GET and POST without any particular errors.
  When trying the same by Angular(Chrome\FireFox\IE Browser) I'm getting the following errors.</p>
  <p><code>zone.js:3243 OPTIONS http://localhost:8888/api/PaymentDetails 405 (Method Not Allowed)</code>
  <code>ccess to XMLHttpRequest at 'http://localhost:8888/api/PaymentDetails' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</code></p>
  <p>I'll try to share as much as code I can to demonstrate the flow.</p>
  <blockquote>
  <p><strong>WebApi Startup.cs:</strong></p>
  </blockquote>
  <p>public IConfiguration Configuration { get; }</p>
  <pre><code>// This method gets called by the runtime. Use this method to add services to the container.
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddCors(options =&gt;
      {
          options.AddPolicy(&quot;CorsPolicy&quot;,
              builder =&gt;
              builder.AllowAnyOrigin()
                     .AllowAnyMethod()
                     .AllowAnyHeader()
  
                  );
      });
      services.AddControllers()
          .AddJsonOptions(options =&gt;
          {
              options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
              options.JsonSerializerOptions.PropertyNamingPolicy = null;
          });
  
      services.AddDbContext&lt;PaymentDetailContext&gt;(options =&gt; options.UseSqlServer(&quot;Server=DESKTOP-KT0N2RN\\SQLEXPRESS;DataBase=PaymentDetailDB;Trusted_Connection=True;MultipleActiveResultSets=True;&quot;));
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
      app.UseRouting();
  
      app.UseAuthorization();
  
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllers();
      });
  
      app.UseCors(&quot;CorsPolicy&quot;);
  }
  </code></pre>
  <blockquote>
  <p><strong>WebAPi GET method:</strong></p>
  </blockquote>
  <pre><code>[HttpGet]
  public async Task&lt;ActionResult&lt;IEnumerable&lt;PaymentDetail&gt;&gt;&gt; GetPaymentDetails()
  {
      return await _context.PaymentDetails.ToListAsync();
  }
  </code></pre>
  <blockquote>
  <p><strong>Client Side:</strong></p>
  </blockquote>
  <pre><code>rootUrl: string = &quot;http://localhost:8888/api&quot;;
  
  getPaymentDetail()
  {
      
      console.log(`${this.rootUrl}/PaymentDetails`)
      const headers = new HttpHeaders().set('Content-Type','application/json');
      // headers.append('Access-Control-Allow-Origin', '*');
      // headers.append('Access-Control-Allow-Headers','Origin, X-Requested-With, Content-Type, Accept');
      return this._http.get(`${this.rootUrl}/PaymentDetails`,{headers:headers});
  }
  </code></pre>