public static ICorsPolicyProvider AsOwinPolicyProvider(this CorsConfiguration corsConfiguration) { var attribute = new CorsPolicyProvider { PolicyResolver = context => Task.FromResult( CreatePolicy( corsConfiguration.Origin, string.Join(",", corsConfiguration.Methods ?? new List <string>()), string.Join(",", corsConfiguration.Headers ?? new List <string>()), string.Join(",", corsConfiguration.ExposedHeaders ?? new List <string>()) ) ) }; return(attribute); }
public static CorsOptions AsCorsOptions(this CorsConfiguration corsConfiguration) { return(new CorsOptions { PolicyProvider = corsConfiguration.AsOwinPolicyProvider() }); }