CORS not working for calls from Ajax to ASP.NET Core Web API
Solution 1:
Try to use the named policy like this:
services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
and this
app.UseCors("MyPolicy");
And you don't need [EnableCors] in the controller in this case. You need it only if you use AddDefaultPolicy....