title: Angular 9 and .NET Core - access from origin localhost:4200 has been blocked by CORS policy
body: <p>I have application in Angular 9 and backend in .NET Core 3.1
  When I want to make request from angular client:</p>
  <pre><code>private httpHeaders: HttpHeaders;
  
    constructor(private httpClient: HttpClient, @Inject('BASE_URL') private baseUrl: string) {
      this.httpHeaders = new HttpHeaders({
        'Access-Control-Allow-Origin': '*' 
    });
    }
  
   return this.httpClient.get&lt;any&gt;(`${environment.apiUrl}/findUser/GetUsers?name=${name}&amp;lastname=${lastname}`, {
          headers: this.httpHeaders,
        reportProgress: true,
        observe: 'events'
      });
  </code></pre>
  <p>In <code>Startup.cs</code> my settings looks like that:</p>
  <pre><code>services.AddCors();
   services.AddControllers();
  
  app.UseCors(x =&gt; x
                  .AllowAnyOrigin()
                  .AllowAnyMethod()
                  .AllowAnyHeader());
  </code></pre>
  <p>In controller:</p>
  <pre><code>[HttpGet]
  [Route(&quot;getUsers&quot;)]
  public IEnumerable&lt;UserAccountDTO&gt; GetUsers(string name, string lastname)
  {}
  </code></pre>
  <p>But it doesn't work:</p>
  <pre><code>  Access to XMLHttpRequest at 'http://localhost:20677/findUser/GetUsers?
  name=&amp;lastname=John' from origin 'http://localhost:4200' has been blocked by CORS
   policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
  </code></pre>
  <hr />
  <p>This is request:</p>
  <pre><code>GET /findUser/GetUsers?name=&amp;lastname= HTTP/1.1
  Host: localhost:20677
  Connection: keep-alive
  Access-Control-Allow-Origin: *
  Accept: application/json
  Authorization: Bearer xxxxxxxxxxxxxxx
  User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36
  Content-Type: application/json
  Origin: http://localhost:4200
  Sec-Fetch-Site: same-site
  Sec-Fetch-Mode: cors
  Sec-Fetch-Dest: empty
  Referer: http://localhost:4200/find-user
  Accept-Encoding: gzip, deflate, br
  Accept-Language: en-US,en;q=0.9
  </code></pre>