[英]asp.net mvc Azure cloud services, should I use TempData or Sessions to hold some user info or something else
I am developping a website that will be hosted on azure cloud services. 我正在开发一个将在Azure云服务上托管的网站。 I am wondering about the best way to save some information of the logged user (basically some Ids, and a list/dictionary).
我想知道保存已登录用户的一些信息的最佳方法(基本上是一些ID,以及一个列表/词典)。
The app could be deployed on multiple instances. 该应用程序可以部署在多个实例上。 I know for sure that static variables are not a solution.
我肯定知道静态变量不是解决方案。
So is it safe to use Sessions, should I go with TempData (using the peek method or just making a wrapper class that will use the peek method) or something else? 因此使用Session是安全的,我应该使用TempData(使用peek方法还是仅创建将使用peek方法的包装器类)或其他方法?
Basically I would like to avoid calls to the database to retrieve same data because itself is reached through a webservice. 基本上,我想避免调用数据库来检索相同的数据,因为它本身是通过Web服务到达的。
data stored in TempData will be cleared in the next request, it's just a temporary store (eg when you want to maintain data when doing redirect), so it's not a good place to put data that is valid for the whole session TempData中存储的数据将在下一个请求中清除,它只是一个临时存储(例如,当您在重定向时想要维护数据时),因此不是放置对整个会话有效的数据的好地方
Normally user information is stored in 2 ways after successfully log in: 成功登录后,通常以两种方式存储用户信息:
TempData only stores data the time of your HTTP request. TempData仅在HTTP请求时存储数据。 Session is not very reliable, and is memory consuming, as long you don't have a shared Session provider, like a SQLSessionProvider.
只要您没有共享的Session提供程序(例如SQLSessionProvider),Session就不会非常可靠,并且会占用内存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.