public static void RegisterGlobal(HttpConfiguration httpConfig) { var corsConfig = new WebApiCorsConfiguration(); corsConfig.RegisterGlobal(httpConfig); corsConfig.AllowAll(); }
//http://brockallen.com/2012/06/28/cors-support-in-webapi-mvc-and-iis-with-thinktecture-identitymodel/ public static void RegisterCors(HttpConfiguration httpConfig) { WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration(); // this adds the CorsMessageHandler to the HttpConfiguration’s // MessageHandlers collection corsConfig.RegisterGlobal(httpConfig); corsConfig.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.ForAllResources().AllowAllOriginsAllMethodsAndAllRequestHeaders(); corsConfig.AllowAll(); /* corsConfig .ForResources(“Products”) .ForOrigins(“http://foo.com”) .AllowAll();*/ }