我要为多域访问制定动态cors策略。
我制作了CorsPolicyProviderFactory并将其在WebApiConfig中启用。
config.SetCorsPolicyProviderFactory(new DynamicPolicyProviderFactory());
config.EnableCors();
我的演示政策:
var _policy = new CorsPolicy
{
SupportsCredentials = true,
Headers = { "Origin, Content-Type, Accept, X-Request-With, Set-Cookie, Cookie" },
Methods = { "GET" },
Origins = { "http://localhost:49561" }
};
return _policy;
但是它无法通过web.config并获取错误。 如何忽略webconfig策略并使CorsPolicyProviderFactory工作?