tags:

views:

53

answers:

2

Hi all! I'd like to ask for a solution. For example we have a page. And I have a link to a another action from this page. I want to have an ability to save the values of entered data on the page. For instance I go to another page enter data and go back. Like the wizard. But the problem is that we can come to the action from different pages. And it need to save several data types.

Is it understand? Any suggestions?

I'd like to have common solution....

A: 

In the past for wizards I have used Session to store data as it gets built up along the way.

One thing to not forget is to validate the data you are storing in the session everytime you go to use it. If not a user can exploit the back button to fake certain scenarios. For example:

  1. User uses the wizard and gets to step 3 in the wizard.
  2. They then go to another page that is not part of the wizard.
  3. Then the user enters the wizard again and only gets to step 2 of the wizard.
  4. User then uses the back button to go all the way back to the original wizard that they were on step 3 for.

In this case the data in your session if posted will think it came from the original wizard even though the data in the session is reflecting only up to step 2 from when the user accessed the wizard the second time. Use a unique key each time someone starts a wizard and validate it at each step.

Hope that helps and isn't too confusing (it was a bit to me typing it).

An alternative is to persist the data via the TempData but each time you will need to pull it out and persist it for posting back to the next step. Then rebuild it, add to it and repeat. This can be a lot of work as well but at least you don't have to worry about things happening out of synch.

Kelsey
Session is not a good solution cause load balancer is used in front of web servers.Looks like it needs to serialize data, and save in hidden.
Igor
Yes you will need to cache it client side using TempData or as you said serializing to a hidden.
Kelsey
@Igor did you ever get this worked out? If this or another answer helped you, make sure to mark the accepted answer to improve your accepted answer rate and let people know that you no longer need a response.
Kelsey
+2  A: 

You could also use TempData to persist data between requests.

R0MANARMY
That's the MVC way.
DreamSonic