title: MVC 5 Checkbox returns “False,false” or “false”
body: <p>At first glance this post may look like a duplicate, but it's not. Believe me, I've looked all over Stack Overflow to no avail.</p>
  
  <p>Anyway, I'm getting some weird behaviour from Html.CheckBoxFor.</p>
  
  <p>I have a view model with this following defined property</p>
  
  <pre><code>[Display(Name = "User is active")]
  public bool IsActive { get; set; }
  </code></pre>
  
  <p>It's initialized before the view</p>
  
  <pre><code>if (userInfo.isActive != null)
  {
      //Cast to bool because userInfo.isActive is Nullable&lt;bool&gt;
      model.IsActive = (bool)userInfo.isActive;
  }
  
  ModelState.Clear();
  
  return View(model);
  </code></pre>
  
  <p>Then rendered in an Html.BeginForm as</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      @Html.LabelFor(model =&gt; model.IsActive, htmlAttributes: new { @class = "control-label col-md-2" })
      &lt;div class="col-md-10"&gt;
          @Html.CheckBoxFor(model =&gt; model.IsActive, htmlAttributes: new { @value = Model.IsActive /*Also tried @checked = Model.IsActive*/ })
          @Html.ValidationMessageFor(model =&gt; model.IsActive)
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And returned to the controller</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult EditProfile(EditProfileViewModel model, string Roles, HttpPostedFileBase ProfileImage)
  {
      //There's a lot more up here, but it's not relevant to the problem
      userInfo.isActive = model.IsActive;
      var tmp = Request.Form["IsActive"]; //Added just to check the form value
  
      try
      {
          db.Entry(userInfo).State = EntityState.Modified;
          //Assign changed data to userInfo
          db.SaveChanges();
      }
  }
  </code></pre>
  
  <p>When model.IsActive is initialized as true and I don't uncheck the checkbox the value of model.IsActive in the controller post is true, or if I do uncheck the checkbox then the value of model.IsActive comes back as false and everything is hunky-dory.</p>
  
  <p>The problem occurs when model.IsActive is initialized as false. I read a lot of Stack Overflow posts explaining that if the checkbox is unchecked then "false" is returned and if it is checked "true,false" is returned, but that's not the behaviour I'm getting. When the checkbox is initialized as false and I check it in the view the value of model.IsActive still comes back false and when I check the value of the form element (see "var tmp" in controller post) it's "false, false". "True,false" is the expected value, is it not? This only happens when trying to change the model value from false to true, no issues going from true to false.</p>
  
  <p>So Stack Overflow, what the heck is happening?!</p>