void ConfigureCors(CorsConfiguration corsConfig) { corsConfig .ForResources("~/Handler1.ashx") .ForOrigins("http://foo.com", "http://bar.com") .AllowAll(); corsConfig .ForResources("~/Handler1.ashx") .ForOrigins("http://localhost") .AllowMethods("GET", "POST"); corsConfig .ForResources("~/Handler2.ashx") .ForOrigins("http://localhost") .AllowMethods("GET", "POST") .AllowCookies() .AllowResponseHeaders("Foo"); corsConfig .ForResources("~/Handler3.ashx") .ForOrigins("http://localhost") .AllowMethods("GET", "POST", "PUT") .AllowRequestHeaders("Content-Type"); corsConfig .ForResources("~/Handler4.ashx") .ForOrigins("http://localhost") .AllowAllMethods() .AllowCookies() .AllowRequestHeaders("Content-Type", "Foo", "Authorization") .AllowResponseHeaders("Foo"); }
public static void Register(HttpConfiguration config) { CorsConfiguration corsConfig = new CorsConfiguration(); corsConfig.AllowAll(); var corsHandler = new CorsMessageHandler(corsConfig, config); config.MessageHandlers.Add(corsHandler); // authentication configuration for identity controller var authentication = CreateAuthenticationConfiguration(); config.MessageHandlers.Add(new AuthenticationHandler(authentication)); // default API route config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); }
internal CorsFluentSettings(CorsConfiguration config) { this.config = config; }
public CorsEngine(CorsConfiguration configuration) { this.configuration = configuration; }