コード例 #1
0
        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);
        }
コード例 #2
0
 public static CorsOptions AsCorsOptions(this CorsConfiguration corsConfiguration)
 {
     return(new CorsOptions {
         PolicyProvider = corsConfiguration.AsOwinPolicyProvider()
     });
 }