Exemple #1
0
        public static void Register(HttpConfiguration configuration)
        {
            EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "GET, POST, PUT, DELETE");

            configuration.EnableCors(cors);

            configuration.MapHttpAttributeRoutes();

            configuration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            configuration.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

            configuration.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

            configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            UnityActionFilterProvider.Register(UnityConfig.GetContainer(), configuration);
        }
 public static void Shutdown()
 {
     UnityConfig.GetContainer().Dispose();
 }
 public static void Start()
 {
     GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetContainer());
 }