Multi step wizard form with MVC

℡╲_俬逩灬. 提交于 2019-12-04 13:06:58

I always use session. I've seen you concern about the persons not using cookies, but i don't think that is a problem these days as i don't think there are many users denying cookies.

My preference for session is that it's easy to store and retrieve and easy to setup. When you scale out (to more servers) you can easyly setup your application to store the the sessionstate in a sql server database so you're ready for the future too.

Hidden fields i use sometimes when there is not sensitive information stored between the steps, because the user can edit the value of the hidden fields.

If there is a lot of info to share between the posts and you don't want a lot of hidden fields, you can also create an object for your storage (like you would create when you would stoe it in session) and the serialize the object, base64 encode it and store it in ONe hidden field.

Are you opposed to sticking their data into the database? That way, when they go "Prev" you just pull up that page's data from the database. You could just save that page as "temp" or whatever status you want to indicate that the user hasn't officially saved it yet. Then, you don't have to worry about session or anything like that.

TempData is implemented with Session variables behind the scenes, so your concerns for about sessions extend to the use of TempData.

If the wizard was quite long and complicated I would probably persist to a DB, otherwise if it's quite small and simple you could consider storing all the data, for all steps, in form fields and posting all the data between the steps.

I agree with JonoW, I would consider putting hidden fields to store the data between steps (has worked for me)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!