title: Whats the Appropriate Method to pass 2 different Models to the Controller from a View in MVC4
body: <p>I am using MVC4 with SimpleMembership. MVC has setup my UserProfile table and I've modified the Registration View to accomodate my layout. Everything worked great until I determined that I wanted to include some additional information from my user that best fit within the context of another already existing Model.</p>
  
  <p>Typically my approach to passing more than one Model from my View to the Controller has been to employ Tuples. Historically this has worked out great for me and I've never had any real issues until now.</p>
  
  <p>My Registration Form resembles this:</p>
  
  <pre><code>@model Tuple&lt;MyNamespace.Models.RegisterModel,MyNamespace.Models.MembershipDetail&gt;
  
  @using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
  @Html.AntiForgeryToken()     
      &lt;table style="border-collapse: collapse; border-spacing:0px; border-width:0px; margin: 0px; width:100px; padding: 0 0 0 0px; background-color:#2e2e2e;"&gt;
          &lt;tr&gt;
             &lt;td&gt;
                Profile Name
             &lt;/td&gt;
             &lt;td&gt;
                @Html.TextBoxFor(m =&gt; m.Item2.ProfileName)
             &lt;/td&gt;
          &lt;/tr&gt; 
          &lt;tr&gt;
             &lt;td&gt;
                @Html.LabelFor(m =&gt; m.Item1.UserName)
             &lt;/td&gt;
             &lt;td&gt;
                @Html.TextBoxFor(m =&gt; m.Item1.UserName)
             &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
             &lt;td&gt;
                @Html.LabelFor(m =&gt; m.Item1.Password)
             &lt;/td&gt;
             &lt;td&gt;
                @Html.PasswordFor(m =&gt; m.Item1.Password)
             &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
             &lt;td&gt;
                @Html.LabelFor(m =&gt; m.Item1.ConfirmPassword)
             &lt;/td&gt;
             &lt;td&gt;
                @Html.PasswordFor(m =&gt; m.Item1.ConfirmPassword)
             &lt;/td&gt;
          &lt;/tr&gt;                               
          &lt;tr&gt;
             &lt;td&gt;
                &lt;button type="submit" id="btnSubmitForm" value="Register"&gt;Register&lt;/button&gt;
             &lt;/td&gt;
          &lt;/tr&gt;
       &lt;/table&gt;
       @Html.Partial("_ValidationSummary",ViewData.ModelState)                             
     }    
  </code></pre>
  
  <p>The Register Method of my Controller is similar to this:</p>
  
  <pre><code>    [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public ActionResult Register(RegisterModel model, MembershipDetail member)
      {
          if (ModelState.IsValid)
          {
              try
               {
                  // Do something with the data
               }
              catch(MembershipCreateUserException e)
              {
                 ModelState.AddModelError("",ErrorCodeToString(e.StatusCode));
              }
          }
          return View(model);
      }
  </code></pre>
  
  <p>Whenever I debug this code after the click of the Submit button, I note that both Models returned to the controller are empty. The contained fields are either null, 0 or Empty Strings and I cannot figure out why.</p>
  
  <p>To add to this mystery, if I remove the tuple from the top of the view and re-assign it as a single Model as such:</p>
  
  <pre><code>@model MyNamespace.Models.RegisterModel
  </code></pre>
  
  <p>And replace the tuple references from the code (e.g. m.Item1.Property, m.Item2.Property) with the 1 Model inferred reference (m.Property and etc); then the data passed in from the TextBox helpers is appropriately assigned to the model and the model is populated when I debug the code.</p>
  
  <p>Now, I know I could simply add a few other fields to the UserProfile table and use them in my Model to alleviate the Tuple altogether but then I am duplicating data in my schema which is not an ideal solution. And keeping in mind that though my sample code provided here only contains 1 element of the 2nd Model, it will actually be more than 1.</p>
  
  <p>So why don't the Models get populated when using the Tuple and is there a more appropriate way to go about solving this problem? Or can I not mix Model data on a single form submission???</p>