My IDE is Visual Studio 2017. I\'ve got an Angular4 client talking to a WebAPI backend in Core, and CORS is working as configured EXCEPT for the PUT and POST methods. The G
I got it working with very simple approach. I uses dotNet Core 2.0.
In configureServices method of startup
services.AddCors(options =>
{
options.AddPolicy("app-cors-policy",
builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials()
;
});
});
In configure method of startup
app
.UseCors("app-cors-policy") //Must precede UseMvc
.UseMvc();
Then, enable both - Anonymous authentication and Windows authentication as well. This allows OPTIONS requests (preflight) which are anonymous always, to go through. All xhr requests has to be withCredentials else will fail.