开发者

Passing state between an MVC view and a dynamic image [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

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 question

I 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.

  1. Server HTTP Cache
  2. Session
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜