title: Cannot set a custom contract resolver in web api configuration
body: <p>How can I set a custom contract resolver in web api configuration?  My code is relatively new and has no custom contract resolver till now.</p>
  <p>I have added no other customization besides routing.</p>
  <p>I tried in three different ways and none worked:</p>
  <pre><code>public static void Register(HttpConfiguration config)
  {            
      // Web API routes
      config.MapHttpAttributeRoutes();
  
      config.Routes.MapHttpRoute(
          name: &quot;DefaultApi&quot;,
          routeTemplate: &quot;api/{controller}/{action}/{id}&quot;,
          defaults: new { id = RouteParameter.Optional }
      );
  
      //attempt 1
      config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CustomContractResolver();
  
      //attempt 2
      GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CustomContractResolver();
  
      //attempt 3
      JsonConvert.DefaultSettings = () =&gt; new JsonSerializerSettings
      {
          ContractResolver = new CustomContractResolver()
      };           
  }
  </code></pre>
  <p>The custom contract resolver code, breakpoint never reaches here when I'm debugging:</p>
  <pre><code>public class CustomContractResolver : CamelCasePropertyNamesContractResolver
  {
      protected override string ResolvePropertyName(string propertyName)
      {
          var regex = new Regex(@&quot;([_])(\w)&quot;);
  
          if (regex.IsMatch(propertyName))
          {
              var result = regex.Replace(propertyName.ToLower(), (match) =&gt; { return match.Groups[2].Value.ToUpper(); });
              return result;
          }
          else
              return base.ResolvePropertyName(propertyName);
      }
  }
  </code></pre>
  <p>Is there something that is missing?</p>
  <p><strong>Edit 1:</strong></p>
  <p>I'm using ASP.NET WebApi 5.2.1 AND MVC 5.2.7, JSON.NET (Newtonsoft.Json) v13.0.1 (and already tried the old v12)</p>
  <p>My Global Asax is very simple as well:</p>
  <pre><code>public class MvcApplication : System.Web.HttpApplication
  {
      protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();
          GlobalConfiguration.Configure(WebApiConfig.Register); //&lt;- web api configuration
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes); //&lt;- mvc configuration
          BundleConfig.RegisterBundles(BundleTable.Bundles);
      }
  }
  </code></pre>
  <p>The MVC RouteConfig class:</p>
  <pre><code>public class RouteConfig
  {
      public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);
  
          routes.IgnoreRoute(&quot;{resource}.ashx/{*pathInfo}&quot;);
  
          routes.MapRoute(
              name: &quot;Default&quot;,
              url: &quot;{controller}/{action}/{id}&quot;,
              defaults: new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = UrlParameter.Optional }
          );
      }
  }
  </code></pre>
  <p><strong>Edit 2</strong></p>
  <p>Here is some test web api controllers:</p>
  <pre><code>using System.Web.Http;
  
  namespace Kronos.Web.Geolocalizacao.Controllers.Api
  {
      public class TestController : ApiController
      {
          [HttpGet]
          public TestModel Obtain()
          {
              return new TestModel { CODE_IDENTIFICATION = 1, DEFAULT_DESCRIPTION = &quot;TEST DAT THING&quot; };
          }
      }
  
      public class TestModel
      {
          public decimal CODE_IDENTIFICATION { get; set; }
  
          public string DEFAULT_DESCRIPTION { get; set; }
      }
  }
  </code></pre>
  <p>Used the Tabbed Postman chrome addon to test</p>
  <p><a href="https://i.stack.imgur.com/UzVtU.png" rel="nofollow noreferrer">Postman tests</a></p>