public static void RegisterCors(HttpConfiguration httpConfig) { WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration(); corsConfig.RegisterGlobal(httpConfig); corsConfig .ForResources("Values1") .ForOrigins("http://localhost") .AllowMethods("GET", "POST"); corsConfig .ForResources("Values2") .ForOrigins("http://localhost") .AllowMethods("GET", "POST") .AllowCookies() .AllowResponseHeaders("Foo"); corsConfig .ForResources("Values3") .ForOrigins("http://localhost") .AllowMethods("GET", "POST", "PUT") .AllowRequestHeaders("Content-Type"); corsConfig .ForResources("Values4") .ForOrigins("http://localhost") .AllowAllMethods() .AllowCookies() .AllowRequestHeaders("Content-Type", "Foo", "Authorization") .AllowResponseHeaders("Foo"); }
public static void RegisterCors(HttpConfiguration httpConfig) { WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration(); corsConfig.RegisterGlobal(httpConfig); corsConfig.ForResources("Navigation") .ForOrigins("http://localhost:9240") .AllowAll(); }
public static void RegisterCors(HttpConfiguration httpConfig) { WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration(); // this adds the CorsMessageHandler to the HttpConfiguration's // MessageHandlers collection corsConfig.RegisterGlobal(httpConfig); // this allow all CORS requests to the Products controller // from the http://foo.com origin. corsConfig .ForResources("Products") .ForOrigins("http://localhost:8066/api/products") .AllowAll(); }
public static void RegisterCors(HttpConfiguration httpConfig) { var corsConfig = new WebApiCorsConfiguration(); // this adds the CorsMessageHandler to the HttpConfiguration’s // MessageHandlers collection corsConfig.RegisterGlobal(httpConfig); // this allow all CORS requests to the Products controller // from the http://foo.com origin. corsConfig.ForResources("RestfulObjects").ForOrigins("http://localhost:49998", "http://localhost:8080").AllowAll().AllowResponseHeaders("Warning"); }