title: Form serialization in c#
body: <p>I have a page that posts the following form (this is a simple html form):</p>
  
  <pre><code>point[location1][x]:10
  point[location1][y]:20
  point[location2][x]:40
  point[location2][y]:60
  </code></pre>
  
  <p>In an action I can obtain the form values using the following model:</p>
  
  <pre><code>public class PlacesModel
  {
      public Dictionary&lt;string, Dictionary&lt;string, int&gt;&gt; Point { get; set; }
  }
  </code></pre>
  
  <p>Beeing the action:</p>
  
  <pre><code>[HttpPost]
  public ActionResult GetPoints(PlacesModel model)
  {
      // do something with the model here
  
      return View();
  }
  </code></pre>
  
  <p>However, I would rather retrieve the form values with a different model such as:</p>
  
  <pre><code>public class PlacesModel
  {
      public Dictionary&lt;string, Coord&gt; Point { get; set; }
  }
  
  public class Coord
  {
      public int x { get; set; }
      public int y { get; set; }
  }
  </code></pre>
  
  <p>But this doesn't work.
  The dictionary is filled with 2 entries, one for "location1" and one for "location2" but the coord object is never initialized.</p>
  
  <p>Any thoughts on this?</p>