There is a typed View

 @model WebApplication1.Models.EditVM @{ ViewBag.Title = "Edit"; } <h3>Редактирование графика работы по элементу содержания</h3> @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <div class="form-group"> @Html.LabelFor(x => x.CountHours, new { @class = "control-label col-md-2" }) @Html.EditorFor(x => x.CountHours, new { @class = "form-control" }) </div> <div class="form-group"> <div class="col-md-offset-2"> <input type="submit" value="Сохранить" class="btn btn-success" /> </div> </div> </div> } 

Also in the controller there is a method for POST request:

 [HttpPost] public ActionResult Edit(EditVM model) { System.Diagnostics.Debug.WriteLine("Succes!"); return View(model); } 

But after clicking on Сохранить application does not fall into this POST request, but displays:

Server error in application '/'.

For this object, no parameterless constructors are defined.

Description: An unhandled exception occurred during the execution of the current web request. Examine the stack trace for more information about this error and the code snippet that caused it.

Exception Details: System.MissingMethodException: No parameter-less constructors are defined for this object.

For the sake of interest, I created the same post-method without parameters in the controller:

 public ActionResult Edit() { System.Diagnostics.Debug.WriteLine("Validation succes!"); return View(); } 

So really !!! The application processes this particular method). I do not get it.

How can I get a filled model from View?

    1 answer 1

    In the error message

    For this object, no parameterless constructors are defined.

    Most likely it means the class WebApplication1.Models.EditVM - there should be a constructor without parameters. You (probably) have only a constructor in it that requires parameters, and the model binder crashes when you try to create an EditVM object from the incoming data.