开发者

Data Persistence in ViewData verses tempData

开发者 https://www.devze.com 2023-04-06 22:35 出处:网络
I was wonderin开发者_开发知识库g how long Data can persist in the ViewData dictionary.I know data can\'t persist that long in TempData (less than an hour).So how long can it last in ViewData?Is there

I was wonderin开发者_开发知识库g how long Data can persist in the ViewData dictionary. I know data can't persist that long in TempData (less than an hour). So how long can it last in ViewData? Is there another Data dictionary That will persist Data for a long time. I know it is starting to sound like I want a session variable and that is very un-MVC, but is there any other way I can get data from a control to a view without passing it directly as a parameter.


I was wondering how long Data can persist in the ViewData dictionary

It lasts from the moment you put it there to the moment the request ends, i.e. the page is rendered and sent to the client.

I know data can't persist that long in TempData (less than an hour)

TempData is like Session but persists only until the next request. So it could be like seconds, minutes, hours, days, ...

I know it is starting to sound like I want a session variable and that is very un-MVC

I wouldn't say un-MVCish, I would say un-RESTfulish.

Is there another Data dictionary That will persist Data for a long time

Yes, the Session, your underlying data storage (like a database or something), cookies, application scope, cache, ... it will all depend on your specific requirements.

0

精彩评论

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

关注公众号