.NET Core:跨域

  在Startup中的ConfigureServices方法中配置:
services.AddCors(options =>
  options.AddPolicy("any", builder =>
  {
    builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
  }
));

  Configure方法中启用:
app.UseCors("any");

  在控制器中配置:
[EnableCors("any")]
public class TestController : ControllerBase
{
}

猜你喜欢

转载自www.cnblogs.com/liusuqi/p/11883216.html