title: Passing data to partial view
body: <p>I have creating a view page having two partial views login and register.For both ,I created view models and a combined model for both as below.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  using System.Web;
  
  namespace ProjectHub.ViewModels
  {
      public class LoginModel
      {
           public string Username { get; set; }
           public string Password { get; set; }
      }
      public class RegisterModel
      {
           public string FullName { get; set; }
           public string Email { get; set; }
           //Some properties as well
      }
      public class LoginOrRegisterModel
      {
           public LoginModel Loginmodel { get; set; }
           public RegisterModel Registermodel { get; set; }
      }
  }
  </code></pre>
  
  <p>Index.cshtml
       @model ProjectHub.ViewModels.LoginOrRegisterModel</p>
  
  <pre><code> @Html.Partial("_Register", Model.Registermodel) 
   @Html.Partial("_Login",Model.Loginmodel)
  </code></pre>
  
  <p>_Login.cshtml</p>
  
  <pre><code>  @model ProjectHub.ViewModels.LoginModel
  
    @using (Html.BeginForm("Login", "account", FormMethod.Post))
    {
      @Html.ValidationSummary(true)
      &lt;div class="label"&gt;@Html.Label("Username")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.Username)&lt;/div&gt;
  
      &lt;div class="label"&gt;@Html.Label("Password")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.PasswordFor(m =&gt; m.Password)&lt;/div&gt;
  
      &lt;input class="field" id="submit" type="submit" value="Login" /&gt;
  }
  </code></pre>
  
  <p>_Register.cshtml</p>
  
  <pre><code> @model ProjectHub.ViewModels.RegisterModel
  
   @using (Html.BeginForm("Register", "account", FormMethod.Post))
   {
      &lt;div class="label"&gt;@Html.Label("Name")&lt;/div&gt;
      &lt;div class="field"&gt;@Html.TextBoxFor(m =&gt; m.FullName)&lt;/div&gt;
  
      //Some other labels and fields
  
      &lt;input class="field" id="submit" type="submit" value="Sign Up" /&gt;
      @Html.ValidationSummary()   
  }
  
   public ActionResult Index()
      {
          return View();
      }
  </code></pre>
  
  <p>Now, when I try to run application.I got error "Object reference not set to an instance of an object." in Index.cshtml at @Html.Partial("_Register", Model.Registermodel) and @Html.Partial("_Login",Model.Loginmodel).
  Please help me.</p>