Q:

Cannot set DateTime with input field. Always returns DateTime.MinValue

My program is supposed to have a date filter and gives an article with proper date. But when I input any date in my DateTime field, my values don't change and are always DateTime.MinValue. I don't know why and how I can fix it. 
View: 
    <form method="get">
    <div class="form-inline form-group">
        <label class="control-label"> since: </label>
        @Html.TextBox("startdate", Model.StartDate, htmlAttributes: new { @class = "form-control" })
        <label class="control-label"> till: </label>
        @Html.TextBox("enddate", Model.EndDate, htmlAttributes: new { @class = "form-control" })

        <input type="submit" value="Filtr" class="btn btn-default" />
    </div>
</form>

Model:
 public class MainView
{
    public IEnumerable<Article> Articles { get; set; }
    public string Name { get; set; }
    public SelectList Categories { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public List<int> Tags { get; set; }
}

And Controller:
 public  IActionResult Index(int? category, string name, DateTime startdateTime, DateTime enddateTime)
      {

        IQueryable<Article> articles = db.Articles.Include(p => p.Category);
           if (category != null && category != 0)
           {
               articles = articles.Where(p => p.CategoryId == category);
           }

           if (!String.IsNullOrEmpty(name))
           {
               articles = articles.Where(p => p.Name.Contains(name));
           }

           //if (startdateTime == null) startdateTime = DateTime.MinValue;
           if (enddateTime ==DateTime.MinValue) enddateTime = DateTime.Now;
            articles = articles.Where(p => p.Date>=startdateTime && p.Date <= enddateTime);               

         List<Category> categories = db.Categories.OrderBy(p=>p.Name).ToList();
           categories.Insert(0, new Category { Name = "All", Id = 0 });

        MainView viewModel = new MainView
        {

            Name = name,
            StartDate = startdateTime,
            EndDate = enddateTime

        };
           return View(viewModel);
      }

A:

I think your problem is caused by a naming mismatch.
In your view you are declaring a textbox with the name startdate.
In your controller you are expecting it with a parameter named startdateTime.
The same mismatch goes for the enddate.
When you match these names, the parameter binding should be able to match the input values to the DateTime parameters of the controller.
Can you give this a try?

