在Startup中的ConfigureServices方法中配置:
services.AddCors(options =>
options.AddPolicy("any", builder =>
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
}
));
Configure methods enabled:
app.UseCors ( "the any");
In the controller configuration:
[EnableCors ( "the any")]
public class TestController: ControllerBase
{
}