We have very long multi step form i.e. the user has to fill 20 steps and each step has 5 dropdowns/text fields. At every 4th step, we need to send this data to some external API
[HttpPost]
public ActionResult Step1(Step1to4ViewModel model)
{
if (ModelState.IsValid)
{
Session["Step1"] = model;
// Hit External API
return RedirectToAction("Step2");
}
return View(model); // errors
}
[HttpPost]
public ActionResult StepFinal(Step17To20ViewModel model)
{
if (ModelState.IsValid)
{
var myEntity = new MyEntity();
var step1 = Session['Step1'] as Step1to4ViewModel;
// ... similarly for other steps
var step5 = Session['Step5'] as Step17to20ViewModel;
myEntity.step1 = step1;
myEntity.step5 = step5;
db.MyEntities.Add(myEntity);
db.SaveChanges();
Session.Remove('Step1');
// repeat for each step in session
return RedirectToAction("Success");
}
// errors
return View(model);
}
I have following doubts:
- Should we use "Session" storage for such a length form?
- How "Session" storage is managed? Is it managed on server side OR on client+server side?
- I understand benefits of using session storage but is there any downside of using session storage?