title: How to POST input type date to MVC controller
body: <p>I'm having trouble posting date value from MVC Razor view to MVC Controller</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>@using (Html.BeginForm("MainframeFilingDetail", "Report", FormMethod.Post,     htmlAttributes: new { @class = "form-inline", id = "formDetails" }))
  {
  &lt;div class="form-group"&gt;
      &lt;label id="ReportBeginDate"&gt;Report Begin Date&lt;/label&gt;
      &lt;input type="date" id="BeginDate" value="@DateTime.Today.ToString("yyyy-MM-dd")"/&gt;
  &lt;/div&gt;
  
      &lt;div class="form-group"&gt;
          &lt;label id="ReportEndDate"&gt;Report End Date&lt;/label&gt;
          &lt;input type="date" id="EndDate"  value="@DateTime.Today.ToString("yyyy-MM-dd")"/&gt;
      &lt;/div&gt;
  
      &lt;input id="submit" type="submit" value="Submit" class="btn btn-primary pull-right"/&gt;
  </code></pre>
  
  <p>}</p>
  
  <p><strong>MVC Controller</strong></p>
  
  <pre><code>[HttpPost]
  public ActionResult MainframeFilingDetail(DateTime beginDate, DateTime endDate)
  {
      var isValidDate = ValidateDate(beginDate, endDate);
      if(!isValidDate)
      {
          ModelState.AddModelError("", "Invalid Date!");
      }
  
      var mainframeData = GetMainframeData();
  
  
      return View(mainframeData);
  }
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>When I click the submit button I get exception although I have default value in date input type. I cannot have null values passed to the controller.</p>
  
  <blockquote>
    <p>The parameters dictionary contains a null entry for parameter
    'beginDate' of       non-nullable type 'System.DateTime' for method
    'System.Web.Mvc.ActionResult MainframeFilingDetail(System.DateTime,
    System.DateTime)' in
    'SOS.BusinessFilings.Web.Int.Controllers.ReportController'. An
    optional parameter must be a reference type, a nullable type, or be
    declared as an optional parameter. Parameter name: parameters</p>
  </blockquote>