5

If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Dane O'Connor
  • 75,180
  • 37
  • 119
  • 173

5 Answers5

9

Investigate the post-redirect-get pattern.

http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx
http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framework.aspx

Use that along with a robust domain model (for tracking steps or form completion state or whatever you call it) and you're golden.

Matt Hinze
  • 13,577
  • 3
  • 35
  • 40
1

I left the page flow up to the view, where I believe it belongs, so different views could have different page flows (e.g. for desktop browser clients or mobile phone clients etc.) I wrote it up on my blog: A RESTful Wizard Using ASP.Net MVC… Perhaps?

1

In order to keep the steps you could implement a page flow action filters, which provide an experience like this one:

[RequiredStep(FlowStart = true)]
public ActionResult Confirm()
{
    return View();
}

[RequiredStep (PreviousStep = "Confirm")]
public ActionResult ExecuteOrder()
{
    return RedirectToAction("ThankYou");
}

[RequiredStep(PreviousStep = "ExecuteOrder")]
public ActionResult ThankYou()
{
    return View();
}
CodeClimber
  • 4,109
  • 4
  • 32
  • 44
0
public class CreateAccountWizardController : Controller
{
   public ActionRresult Step1()
   {
   }


   public ActionResult Step2()
   {
   }
}
Ben Scheirman
  • 40,531
  • 21
  • 102
  • 137
-1

There are a couple ways, create an action for each step of the wizard process, or create a parameter that is passed in to the action method. Like step that will allow you to know what the state of the wizard is in.

Nick Berardi
  • 54,393
  • 15
  • 113
  • 135