title: How to include all custom object property in MVC 4 HttpPost
body: <p>I have a view model with a custom object. On the initial get, I populate Foo and use a couple of Foo's properties.</p>
  
  <p>On the post, I find that Foo on the view model is null. </p>
  
  <p>I could add to my view, <code>@Html.HiddenFor(x =&gt; x.Foo.Id)</code> which could ensure that a Foo is populated with at least an Id, but then I could need to add similar code for all of the properties. </p>
  
  <p>Is there a way to send back the complete object?</p>
  
  <pre><code>public class RequestModel
      {
          public Foo Foo{ get; set; }
  
          [Required]
          [Display(Name = "Comment")]
          public string Comment { get; set; }
      }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult Index(int? id)
  {
     //Populate Foo here using EF and add it to the model
     var model = new RequestModel { Foo = foo };    
     return View(model);
  }
  
  
  
  [HttpPost]
  public ActionResult Index(int? id, RequestModel model)
  {
     return View(model);
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@Html.DisplayTextFor(m=&gt;m.Application.Name)
  </code></pre>
  
  <p>etc</p>