title: MVC binding triggering validations errors
body: <p>I'm trying to get my head around why (data annotation) validation errors are triggering when the page first loads, prior to any Submit/Posts. But more importantly how to fix this.</p>
  
  <p>Reading SO and the interwebs, the reason seems to be model binding triggers validation errors for the view model properties, prior to the view model properties having values. I'm not sure if this is true and what is actually happening, but it sounds legit.</p>
  
  <p>And I've read two workarounds, which sound a bit hacky:
  1. Use the ModelState.Clear in the controller action method on the inital page load, OR
  2. Initialiase the view model properties in an empty view model constructor. (Yet to confirm this technique)</p>
  
  <p>Both these techniques sound like work-arounds. I'd rather understand what is happening and design my code appropriately.</p>
  
  <p>Have others come across this issue? And if so, what are you doing?</p>
  
  <p>Code as requested. Below you can see the Data Annotation validation on Property1 which is being triggered on initial requests, i.e. first page load.</p>
  
  <p>Controller action method (refactored for simplicity):</p>
  
  <pre><code>    public ActionResult Index([Bind(Include = Property1, Property2, Property3, vmclickedSearchButton)] IndexVM vm, string Submit)
      {
          bool searchButtonClicked = (Submit == "Search") ? true : false;
          if (searchButtonClicked)
          {
              PopulateUIData(vm); // Fetch data from database and pass them to VM
  
              if (ModelState.IsValid)
              {
                  vm.clickedSearchButton = true; // Used in the vm to avoid logic execution duing initial requests
  
                  DoWork(vm);
                  }
              }
  
              return View(vm);
          }
  
          // Inital request
          IndexVM newVM = new IndexVM();
          PopulateUIData(newVM); // Fetch data from database and pass to VM
  
          return View(newVM);
      }
  </code></pre>
  
  <p>Design note:
  Ideally I would like to sepate the rendering and submiting logic into separate action methods.
  I.e. rendering within a [HttpGet]Index() action method, and submitting within a [HttpPost]Index() action method.
  But since I'm using ForMethod.Get in the View as this method is used for searching functionality, I can only use a [HttpGet] Index action method.</p>
  
  <p>View Model (refactored for simplicity):</p>
  
  <pre><code>public class IndexVM
  {
      // DropDownLists
      public IEnumerable&lt;SelectListItem&gt; DDLForProperty1 { get; set; }
      public IEnumerable&lt;SelectListItem&gt; DDLForProperty2 { get; set; }
      public IEnumerable&lt;SelectListItem&gt; DDLForProperty3 { get; set; }
  
      [Required]
      public int? Property1 { get; set; }       
      public int? Property2 { get; set; }
      public int? Property3 { get; set; }
      public bool vmclickedSearchButton { get; set; }
  }
  </code></pre>
  
  <p>Note:
  The view model is very simple. It contains drop down lists, selected properties for the DDLs, and a validation rule on one of the properties.</p>
  
  <p>Adding a constructor to the view model and initialising the property workaround:</p>
  
  <pre><code>public IndexVM()
  {
    this.Property1 = 0;
  }
  </code></pre>