title: No 'Access-Control-Allow-Origin' header is present - asp.net core web api targeting .net framework 4.5.1
body: <p>I have a server side RESTful API that was created in c# targeting .NET Framework 4.5.1 and the CORS configuration i have does not appear to be working...</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services) {
  
          services.AddCors(options =&gt; {
              options.AddPolicy("AllowAll",
                      builder =&gt; {
                          builder.AllowAnyOrigin()
                                 .AllowAnyMethod()
                                 .AllowAnyHeader()
                                 .AllowCredentials();
                      });
          });
  
          // Add framework services.
          services.AddMvc();
          services.AddOptions();
      }
  
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, 
  ILoggerFactory loggerFactory) {
          loggerFactory.AddConsole(Configuration.GetSection("Logging"));
          loggerFactory.AddDebug();
  
          if (env.IsDevelopment()) {
              app.UseDeveloperExceptionPage();
          }
  
          var options = new JwtBearerOptions {
              Audience = "MyAudience"
              Authority = "MyAuthority"
          };
  
          app.UseJwtBearerAuthentication(options);
          app.UseCors("AllowAll");
          app.UseMvc();
      }
  </code></pre>
  
  <p>Each time i make a call to the below API in my controller </p>
  
  <pre><code>[Authorize]
  [HttpGet]
  public Task&lt;JsonResult&gt; Get() {
  
  ICollection&lt;string&gt; abc;
  try {
      abc = new List&lt;string&gt;(){"A", "B", "C"};
  } catch (Exception) {
      abc = null;
  }
  return Json(abc);
  }
  </code></pre>
  
  <p>I get the following error...</p>
  
  <p>"XMLHttpRequest cannot load x Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'x' is therefore not allowed access. The response had HTTP status code 502."</p>
  
  <p>The http request from my client has an "Authorization" header in it which is why a preflight response is triggered, it has a valid token etc... so it has nothing to do with this part.</p>
  
  <p>In fact if I create the exact same RESTful API targeting .NET Core 1.0, it works as expected. This leads me to believe there is either an issue with CORS and targeting .NET Framework 4.5.1 or there is now some explicit logic i have to add that is otherwise handled implicitly by .NET Core 1.0.</p>
  
  <p>My understanding is that the CORS middleware should be handling all this, does anyone know what the issue might be here?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I forgot to mention that this works fine running as localhost, i only see this issue after deploying. Also, i tested this targeting .NET Framework 4.6.2 and the issue remained.</p>