title: Angular 4 / Asp.net Web API - No 'Access-Control-Allow-Origin' header is present
body: <p>I'm trying to call the API from angular and getting this errors.
  I donot want to set proxy in angular instead allow CORS in Angular 4 and Web API.</p>
  
  <p>Following is my code:</p>
  
  <pre><code>let reHeader: RequestOptions = new RequestOptions();
          reHeader.headers = new Headers();
          reHeader.headers.append("content-type", "application/json");
          reHeader.headers.append("x-api-key", store.APIKey);
          reHeader.headers.append('Access-Control-Allow-Origin','*');
          reHeader.headers.append('Access-Control-Allow-Methods', "GET, POST, PATCH, PUT, DELETE, OPTIONS")
          reHeader.headers.append('Access-Control-Allow-Headers', "Origin, Content-Type, X-Auth-Token")
          switch (rtype) {
              case "get":
                  let query: string = "";
                  action.ActionParams.forEach(m =&gt; {
                      query += "&amp;" + m.Key + "=" + m.Value;
                  });
                  url = url + query;
                  return this.http.get(url, reHeader);
              default:
                  return Observable.of(null);
          }
  </code></pre>
  
  <p>and from WEB API in startup.cs</p>
  
  <pre><code>    public void Configuration(IAppBuilder app)
              {
                  app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
  // ASPNETCORE_ENVIRONMENT should be set to 'Development'
              if (env != null &amp;&amp; env.IsDevelopment())
              {
                  app.UseErrorPage(ErrorPageOptions.ShowAll);
              }
  
              var config = new HttpConfiguration();
              ConfigureWebApi(config);
              // Swagger
              SwaggerConfig.Register(config);
              // Register routes
              WebApiConfig.Register(config);
               }
  </code></pre>
  
  <p>I have checked other posts but still didnt get solution.
  -  <a href="https://stackoverflow.com/questions/48032316/angular-2-response-to-preflight-request-doesnt-pass-access-control-check-no-a">Angular 2 Response to preflight request doesn&#39;t pass access control check: No &#39;Access-Control-Allow-Origin&#39; header</a></p>