How do I handle page flow in MVC (particularly asp.net)

后端 未结 5 1849

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

相关标签:
5条回答
  • 2021-02-10 01:40

    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.

    0 讨论(0)
  • 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?

    0 讨论(0)
  • 2021-02-10 01:54

    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.

    0 讨论(0)
  • 2021-02-10 01:58
    public class CreateAccountWizardController : Controller
    {
       public ActionRresult Step1()
       {
       }
    
    
       public ActionResult Step2()
       {
       }
    }
    
    0 讨论(0)
  • 2021-02-10 02:00

    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();
    }
    
    0 讨论(0)
提交回复
热议问题