测试配置可行
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
}
SetIsOriginAllowed方法用于判断某个域名是否在允许跨域的名单中,这里不判断直接返回True
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.UseCors(options => options.SetIsOriginAllowed(x => _ = true).AllowAnyMethod().AllowAnyHeader().AllowCredentials());
}
SetIsOriginAllowed方法注释
//
// 摘要:
// /// Sets the specified isOriginAllowed for the underlying policy. ///
//
// 参数:
// isOriginAllowed:
// The function used by the policy to evaluate if an origin is allowed.
//
// 返回结果:
// The current policy builder.
public CorsPolicyBuilder SetIsOriginAllowed(Func<string, bool> isOriginAllowed)
{
throw null;
}