Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

asp.net mvc 3 - MVC3 multi step form - How to persist model object

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 people suggest using HTML.Serialize but how secure is this option?

Also my model object will grow as the user fills up the form which means the hidden form field with serialized data will add up size to my HTML output.

Whats the best practice for this kind of situation?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...