public static void Register(HttpConfiguration config)
        {
            //if (System.Diagnostics.Debugger.IsAttached)
            //	config.EnableSystemDiagnosticsTracing();

            #region Custom Controller Selector

            // Web API routes
            config.MapHttpAttributeRoutes(new InheritableDirectRouteProvider());             // Allow for inheritance of the RoutePrefix attribute (see: stackoverflow.com/questions/19989023/net-webapi-attribute-routing-and-inheritance)

            #endregion Custom Controller Selector

            // clear the supported mediatypes of the xml formatter
            config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(
                new MediaTypeHeaderValue("application/json-patch+json"));

            config.Formatters.Add(new BsonMediaTypeFormatter());

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.Formatting       = Newtonsoft.Json.Formatting.Indented;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            LogActionAttribute laa = new LogActionAttribute();
            config.Filters.Add(laa);

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            // DryIoC registration.
            config.RegisterDependencyResolver();
        }
Пример #2
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            #region Custom Controller Selector

            // Web API routes
            config.MapHttpAttributeRoutes(new InheritableDirectRouteProvider());             // Allow for inheritance of the RoutePrefix attribute (see: stackoverflow.com/questions/19989023/net-webapi-attribute-routing-and-inheritance)

            #endregion Custom Controller Selector

            // clear the supported mediatypes of the xml formatter
            config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(
                new MediaTypeHeaderValue("application/json-patch+json"));

            config.Formatters.Add(new BsonMediaTypeFormatter());

            var json = config.Formatters.JsonFormatter;
            json.SerializerSettings.Formatting       = Newtonsoft.Json.Formatting.Indented;
            json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            LogActionAttribute laa = new LogActionAttribute();
            config.Filters.Add(laa);

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

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

            // DryIoC registration.
            config.RegisterDependencyResolver();
        }