Search code examples
asp.netdesign-patternswizardpost-redirect-get

ASP.NET Wizard with Post/Redirect/Get


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.


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.