ASP.NET Core 内置了对 CORS 的支持,使用很简单,只需先在 Startup 的 ConfigureServices() 中添加 CORS 策略:
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options => options.AddPolicy( "AllowSameDomain",
builder => builder.WithOrigins( "http://www.cnblogs.com", "https://q.cnblogs.com", "https://zzk.cnblogs.com", "https://i.cnblogs.com", "https://news.cnblogs.com", "https://job.cnblogs.com")));
}然后在想启用 CORS 的控制器 Action 上应用这个策略:
网友评论


