title: MVC5 ViewModel binding in HTTP GET?
body: <p>
  I have an action like this</p>
  
  <pre><code>public ActionResult Overview(TimeAxisVM TimeAxis = null)
  {
      return View(new OverviewVM());
  }
  </code></pre>
  
  <p>View model like this</p>
  
  <pre><code>public class TimeAxisVM
  {
      // omitted ctor
  
      [DataType(DataType.DateTime)]
      public DateTime? From { get; set; }
  
      [DataType(DataType.DateTime)]
      public DateTime? To { get; set; }
  }
  </code></pre>
  
  <p>An editor template for the view model</p>
  
  <pre><code>@model TimeAxisVM
  
  @using (Html.BeginForm("Overview", "Controller", FormMethod.Get))
  {
      @Html.EditorFor(model =&gt; model.From)
  
      @Html.EditorFor(model =&gt; model.To)
  
      &lt;button type="submit"&gt;Submit&lt;/button&gt;
  }
  </code></pre>
  
  <p>And a view for the Overview action like this</p>
  
  <pre><code>@model OverviewVM
  
  @Html.EditorFor(model =&gt; model.TimeAxis)
  </code></pre>
  
  <p>When I execute the GET request this is the query string is TimeAxis.From=22.+02.+2014&amp;TimeAxis.To=25.+02.+2014 but once in the action TimeAxis.From and TimeAxis.To are both null. </p>
  
  <p>If I change the form method to POST it immediately works as expected. From design point of view this should/has to be a GET request.</p>
  
  <p>Any ideas how to make the model binding work for GET?</p>
  
  <p>UPDATE:</p>
  
  <p>Changing the action to</p>
  
  <pre><code>public ActionResult Overview(DateTime? From = null, DateTime? To = null)
  </code></pre>
  
  <p>and sending the request in this form: .../Overview/?From=22.+02.+2014&amp;To=25.+02.+2014 works as well.</p>
  
  <p>But I'd like to keep it encapsulated in the class and dont need to change the input field name - EditorFor generates them as TimeAxis.From and TimeAxis.To. I might add other properties to the ViewModel/form.</p>