1

I am creating multiple views. Each view is having next,previous buttons. When user click next button we will pass the previous pages data.

When user clicks Previous data we have to show the data which is previously entered.

For this approach I have used Sessions to be persist the data across the all views.

But session are very dangerous and heave objects.

Can anyone please suggest me an another approach.

public ActionResult CustomerInfo(Registration registration)
{
  if (ModelState.IsValid)
  {
    Session[SessionKeys.RegistrationStep1] = registration;
    return RedirectToAction("EquipmentOwnerInfo");
  }
  return View(registration);
}

public ActionResult CustomerInfo(string from)
{
  if (Session[SessionKeys.RegistrationStep1] != null)
  {
    registration = (Registration)Session[SessionKeys.RegistrationStep1];                 
  }
  return View(registration);
}
Satya
  • 185
  • 1
  • 2
  • 16
  • 1
    One alternative is to include all controls in one form, but in hidden sections which can be shown and validated one step at a time, then post the whole model at once. [Refer this answer](http://stackoverflow.com/questions/25643394/mvc-force-jquery-validation-on-group-of-elements/25645097#25645097) for an example. –  Mar 11 '15 at 10:48
  • Yes you are right. But here I have used strongly typed required field models. So if we hide based on the page then the validations will be fired. So how can we handle those one? – Satya Mar 11 '15 at 10:59
  • Read the link I gave you! - its takes care of validating just one section of the form at a time (you cant advance to the next step until all controls in the current section are valid) –  Mar 11 '15 at 11:08
  • `But session are very dangerous ` why? – U r s u s Mar 11 '15 at 11:11
  • @Ursus, Probably a reference to [this question/answer](http://stackoverflow.com/questions/10181629/why-session-is-a-disaster-in-asp-net-mvc-application) or one of the many others recommending against it –  Mar 11 '15 at 11:16

0 Answers0