MVC3 multi step form - How to persist model object

前端 未结 2 835
既然无缘
既然无缘 2020-12-15 11:53

I have a multi step form which uses one model object and I need to persist it between the steps. The object gets saved to the database only after the final step. I have seen

相关标签:
2条回答
  • 2020-12-15 11:55

    I've use the TempData for this purpose.

    You can store an object (a copy of your model data) in TempData, and use it in the next request. If it is not set-back in the next request it will be "destroyed". So you do not have to worry that it is filling up your session.

    0 讨论(0)
  • 2020-12-15 12:13

    Think about your Controller as a state machine where every action is a step in the wizard. About the persistence between steps is not big deal anyway is a simple POCO as a Dto, Command which is gonna to be send to your domain interface for validation and processing. You can store it in your IoC, Session, Cache, FileSystem ... I hope you got it. Keep it simple and clean.

    0 讨论(0)
提交回复
热议问题