title: MVC 3 Remote Validation of object not working
body: <p>I realize this question has already been asked plenty of times. However none of the solutions worked for me.</p>
  
  <p>The problem:</p>
  
  <p>I have an object:</p>
  
  <pre><code>public class SomeObject
  {
      [Remote("MyAction", "MyController")]
      public DateTime MyDate { get; set; }
  }
  </code></pre>
  
  <p>And a model: </p>
  
  <pre><code>public class SomeModel
  {
      public SomeObject MyObject { get; set; }
  }
  </code></pre>
  
  <p>and my action:</p>
  
  <pre><code>public JsonResult MyAction(DateTime MyDate)
  {
       //do some validation here
  }
  </code></pre>
  
  <p>When the validation kicks in, because its a complex object it sends a URL like this:</p>
  
  <pre><code>http://localhost/MyController/MyAction?MyObject.MyDate=xxxxxxxx
  </code></pre>
  
  <p>Obviously this means that my action wont pick up the date because the parameter name does not match the querystring name. </p>
  
  <p>I've searched far and wide and saw lots of suggestions - all of which I've tried but none have worked. The following was what I tried:</p>
  
  <p>Using the bind attribute</p>
  
  <pre><code>public JsonResult MyAction([Bind(Prefix = "MyObject")]DateTime MyDate)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public JsonResult MyAction([Bind(Prefix = "MyObject.MyDate")]DateTime MyDate)
  </code></pre>
  
  <p>the date just comes back as null</p>
  
  <p>Using the model or the object as the parameter type</p>
  
  <pre><code>public JsonResult MyAction(SomeObject myObject)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public JsonResult MyAction(SomeModel myModel)
  </code></pre>
  
  <p><code>MyDate</code> always ends up as MinValue, but the parameters (SomeModel or SomeObject) are not null</p>
  
  <p>I'm not quite sure what I'm doing wrong. Can anyone point me in the right direction? Are there any incantations I have to chant prior to running, or perhaps does it have to be sunny outside? This seems to be far more work for a common scenario than expected.</p>