Question

I am getting used to the Post/Redirect/Get pattern, I find it a very good procedure and it also seems to get me thinking more about page structure and not relying on ASP.Net events too often.

I am currently writing a wizard feature for a site, though not using the ASP.NET Wizard control, but handling it more manually with a MultiView. Typically in the past I would have expected the typical user experience to be GET > POST > POST > POST etc. for each successive step of the wizard. However I am now thinking of using a more P/D/G approach, do people often do this with their wizards?

My current thinking is that once a step has been completed by a user and they choose to continue, my session object containing the current wizard information will be saved back to the session and then a GET redirect will be made back to the wizard page. When the wizard page loads the Session object is interrogated to determine the correct step to display to the user.

I can see two good advantages with this:

  1. that it comes with the usual benefit of P/R/G and it eliminates the Refresh problem and also
  2. a user can navigate away from the wizard and come back to it (if their session is still active) and they will be taken straight to the correct step.

Do people consider this a cleaner design? Are there obvious drawbacks? I'm thinking I might be turning into more of a cynical programmer and trusting ASP.Net and the Postback lifecycle less, but it's not as if this approach will result in much more code? If I didn't implement it I'd have to write in all the checks against a user refreshing or trying to navigate to steps they shouldn't anyway.

Was it helpful?

Solution

Yes this is a cleaner design.

The only drawbacks are the additional roundtrip (for the redirect) and the slightly increased complexity of displaying status messages.

I never return POST results to users anymore.

OTHER TIPS

One problem with the approach as you have described it is there is no 'back' functionality, which is a typical expectation with Wizards. Also, be aware that someone may expect to be able to progress through multiple 'sessions' of the wizard at the same time in different browser tabs, and your system would prevent that.

The 'Back' functionality can be included with a special Query String value put in the 'Back' link/button which instructs the session-stored object to back things up a step. The multiple-instance in one session would require something more involved; perhaps simply storing the data in the view state, or creating a key for the 'wizard instance'. Or, you may decide to only support a single instance of the wizard to run at any one time. (admittedly, it may be an extremely rare case that someone tries to run multiple wizard instances at once, anyway)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top