title: Can't make MVC4 WebApi include null fields in JSON
body: <p>I'm trying to serialize objects as JSON with MVC4 WebAPI (RTM - just installed VS2012 RTM today but was having this problem yesterday in the RC) and I'd like for all nulls to be rendered in the JSON output. 
  Like this: </p>
  
  <pre><code>[{"Id": 1, "PropertyThatMightBeNull": null},{"Id":2, "PropertyThatMightBeNull": null}]
  </code></pre>
  
  <p>But what Im getting is </p>
  
  <pre><code>[{"Id":1},{"Id":2}]
  </code></pre>
  
  <p>I've found this Q/A <a href="https://stackoverflow.com/questions/11996314/webapi-doesnt-serialize-null-fields">WebApi doesnt serialize null fields</a> but the answer either doesn't work for me or I'm failing to grasp where to put the answer.</p>
  
  <p>Here's what I've tried:</p>
  
  <ol>
  <li><p>In Global.asax.cs's Application_Start, I added:</p>
  
  <pre><code>var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
  json.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include;
  json.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
  </code></pre>
  
  <p>This doesn't (seem to) error and seems to actually execute based on looking at the next thing I tried.</p></li>
  <li><p>In a controller method (in a subclass of ApiController), added:</p>
  
  <pre><code>base.Configuration.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include;
  base.Configuration.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
  </code></pre>
  
  <p>I say #1 executed because both values in #2 were already set before those lines ran as I stepped through.</p></li>
  <li><p>In a desperation move (because I REALLY don't want to decorate every property of every object) I tried adding this attrib to a property that was null and absent:</p>
  
  <pre><code>[JsonProperty(DefaultValueHandling = DefaultValueHandling.Include,
      NullValueHandling = NullValueHandling.Include)]
  </code></pre></li>
  </ol>
  
  <p>All three produce the same JSON with null properties omitted.</p>
  
  <p>Additional notes: </p>
  
  <ul>
  <li>Running locally in IIS (tried built in too), Windows 7, VS2012 RTM.</li>
  <li>Controller methods return List -- tried IEnumerable too</li>
  <li>The objects I'm trying to serialize are pocos.</li>
  </ul>