3

I have decided to use ASP.NET MVC to develop multi page (registration) forms in asp.net. There will be two buttons on each page that allows the user to navigate to the previous and next page. When the user navigates back to a page they recently filled out, the data should be displayed to them. I understand ASP.NET MVC should remain stateless but how should I maintain page information when the user navigates back and forth.

Should I?

  1. Save the information to a database and retrieve information for each page change?
  2. save information to the session?
  3. Load all the fields and display only whats's needed with javascript?

This registration form is going to be used in multiple sites but with different sets of questions (Some may be the same). IF performance is a main concern, should I avoid generating these forms dynamically?

Jay

1 Answer 1

3

This sounds like the kind of information that you would want to store in a user session. What session store is used can be configured, so you could use a database to store session for users if that would be a better fit than using in-process session.

Sign up to request clarification or add additional context in comments.

5 Comments

Depending how far you want to go and how much DI you are using, you may want to hide the actual storage mechanism behind an interface so you can swap implementation at a later date if your needs change
@Neal - good point. I think you just need to implement IHttpSessionState - msdn.microsoft.com/en-us/library/…
Neal do you mean using a seperate interface to implement saving the information into a database or saving session state into the db?
Create a simple interface e.g. IWorkflowState with 2 methods Store and Retrieve. Create an implementation of that to act as a facade to session state. This means you can easily test by mocking IWorkflowState and if you decide to change to storing the data in the database you simply change the implementation.
Neal - great pattern. In MVC you can easily mock the whole context so you could do it with or without a facade

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.