I have this very simple MVC controller in .net-core net7.0, using c#10
public class HomeController : Controller
{
public IActionResult Index(VolatilityViewQueryModel model = null)
{
if (model is null)
{
model = new VolatilityViewQueryModel
{
BigInterval = 365,
SmallInterval = 7
};
}
return View(model);
}
[HttpPost]
public IActionResult Calculate([FromForm]VolatilityViewQueryModel query)
{
//here i will go to a service to get some data, this is just to make the example easier to understand
query.Data = new VolatilityResult[] { new VolatilityResult() };
return RedirectToAction(nameof(Index), new { model = query});
}
}
the problem is that at Index method it never arrives the value i send in the Calculate method, it always arrives a new instace of the VolatilityViewQueryModel class. Why is that?
Thanks in advance