Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this questionI have a fairly simple MVC view that allows for dynamic text input that is then rendered as an image based preview on the same page (IMG tag). I am currently passing the text as part of the image URL but occasionally the text length exceeds the开发者_运维技巧 URL length.
I can instead POST the text back to the server via AJAX and then pass some type of ID to the image generation controller. My question: what might be the most reasonable approach to maintaining that state? Guessing there is no absolutely correct answer.
- Server HTTP Cache
- Session
- Direct database updates
I wouldn't normally consider storing something like this in a database, but it does have to wind up there eventually.
I would do an ajax POST, and have the server respond with a url to the image (using your ID approach). Since this is just a preview, I assume it could change and there isn't much point saving it in the db since the user may decide to use different text. Just store the id in session state since it is user-specific and short-lived, which is the scope you need for this task.
精彩评论