Multi-Step Form with MVC

I plan to create a multi-stage form with asp.net mvc 2. So, my web application will have 5 pages corresponding to 5 steps. At each step, there are two submit buttons, the previous and the next. Input data for each step will be saved for later viewing. For example, we already entered the data for step s 1,2,3,4, and now we are at step 5. When I press the “previous” 2 times, step 3 should be displayed with the previously entered data. Similarly, when I click "next", the input should also be stored in step 4 (since we are now in step 3). The model used for each step can be very different.

I am looking for a solution to save data for each step. I think of session and tempdata, both of them have disadvantages that I have to consider in order to use

  • Session

    • The default session is a cookie session, so the session will not work if the web browser does not support cookies. I am also concerned here, when IE does not support cookies, the session variable will be lost only if the host name is used to access the web application . The session works fine in IE with an IP address .
    • Cookies less session: unsafe, have many restrictions and have a problem with the message (http://stackoverflow.com/questions/3972433/mvc2-cookieless-session-issue-using-post or http://forums.asp.net/p /1517391/3634908.aspx )
  • Tempdata: tempdata is simply saved for a single request.

I really appreciate your advice!

Many thanks!

+3
source share
4 answers

I always use a session. I saw that you are worried about people who don’t use cookies, but I don’t think that this is a problem these days, because I don’t think that many users refuse cookies.

My preference for a session is that it is easy to store, retrieve, and easy to configure. When you scale (to more servers), you can easily configure the application to store session state in the SQL Server database so that you too are ready for the future.

, , , .

, , (, , ) , base64 ONe.

+2

? , "Prev", . "" - , , . - .

+1

TempData Session , TempData.

, , , , , , .

0

I agree with JonoW, I would think about hiding hidden fields for storing data between steps (worked for me)

0
source

Source: https://habr.com/ru/post/1777483/


All Articles