title: MVC Model Binding Complex Type to Action Parameter
body: <p>I'm binding a list of customers into a customer search results page using the model binding of MVC3, and using Razor to render all the customers in a foreach loop.  My question is how then to send back the customer object to the action to save me having to fetch the details again.</p>
  
  <p>Below is my action method signature:</p>
  
  <pre><code>public ActionResult BasketAddCustomer(Customer customer)
  </code></pre>
  
  <p>The Customer object is quite large, ie. lots of fields</p>
  
  <p>Below is a cut down version of the view which renders each customer and has the button to select each one.</p>
  
  <pre><code>@model WebUI.Models.SearchModel
  @foreach (var customer in Model.Customers)
      {
                  &lt;h5&gt;@customer.FirstName @customer.LastName&lt;/h5&gt;
                  &lt;button onclick="window.location.href = '@Url.Action("BasketAddCustomer", "Cust", customer)';"&gt;Select customer&lt;/button&gt;                    
      }
  </code></pre>
  
  <p>The problem with this is that the customer that is passed into the action seems to come through as being full of nulls.</p>
  
  <p>The html that is rendered by the @URL.Action is below and looks like a good start but only has some of the customer fields, not all.  Is the Customer just too complex for being broken down this way? Is there a better way to do it?</p>
  
  <pre><code>&lt;button onclick="window.location.href = 
  '/Test/Cust/BasketAddCustomer?BirthDate=01%2F01%2F0001%2000%3A00%3A00&amp;amp;PrimaryEmailFlag=False&amp;amp;PrimaryEmailDate=01%2F01%2F0001%2000%3A00%3A00&amp;amp;PrimaryEmailID=0&amp;amp;PrimaryPhoneFlag=False&amp;amp;PrimaryPhoneDate=01%2F01%2F0001%2000%3A00%3A00&amp;amp;PrimaryPhoneID=0&amp;amp;WifiConnected=False';" &gt;Select customer&lt;/button&gt;
  </code></pre>