允许跨域访问Cors
WebApi 项目Program.cs 配置
//允许跨域访问 builder.Services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => { builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowAnyOrigin(); }); });
var app = builder.Build(); app.UseCors("AllowAllOrigins");//允许跨域访问