Hi everyone,
using a functioning sample solution as model, I'm trying to implement an action of type HttpPost to handle a simple html form but for some reason the model's properties are left with default values during the call to the action.
The html saw in the browser seems identical to the one that is working.
Please can you help me finding what I'm missing?
This is the Action
[HttpPost] public IActionResult SetGroundTarget(NewTargetViewModel target) { //_modelProvider.GroundFloorManager.TargetTemperature = target.Target; return View(); }
This is the View:
@model CasinaWebApp.ViewModels.NewTargetViewModel @section scripts { <script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script><script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> }<h2>Set Target Temperature</h2><form method="post"><span asp-validation-summary="ModelOnly"></span><label asp-for="Target"></label><input asp-for="Target" /><span asp-validation-for="Target"></span><label asp-for="Name"></label><input asp-for="Name" /><span asp-validation-for="Name"></span><div><input type="submit" value="Set Target" /></div></form>
This is the View Model:
public class NewTargetViewModel { [Required] public string Target { get; set; } [Required] public string Name { get; set; } }
Thanks in advance,
Guglielmo