public void EnableCors_NullConfig_Throws() { Assert.ThrowsArgumentNull(() => { CorsHttpConfigurationExtensions.EnableCors(null); }, "httpConfiguration"); }
public static void Register(HttpConfiguration config) { EnableCorsAttribute enableCorsAttribute = new EnableCorsAttribute("*", "*", "*"); CorsHttpConfigurationExtensions.EnableCors(config, (ICorsPolicyProvider)enableCorsAttribute); HttpConfigurationExtensions.MapHttpAttributeRoutes(config); config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", (object)new { id = RouteParameter.Optional }); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); EnableCorsAttribute val = new EnableCorsAttribute("*", "*", "*"); CorsHttpConfigurationExtensions.EnableCors(config, val); config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); config.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver(); config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }
public static void Register(HttpConfiguration config) { config.MapHttpAttributeRoutes(); EnableCorsAttribute val = new EnableCorsAttribute("*", "*", "*"); CorsHttpConfigurationExtensions.EnableCors(config, val); config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); config.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver(); config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //var appXmlType =config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); //config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType); }