想知道静态可靠吗? [英] Wanted to know about Static veriable?

查看:87
本文介绍了想知道静态可靠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在我的应用程序中有Employee类,并且我有一个静态属性,即EmployeeName。

并托管我的应用程序那个时间

user1访问该属性并分配该属性的价值。

之后

user2访问该属性并为该属性赋值,user1获取user2的最新值我该如何避免。

If i have Employee class in my application and i have a property as a static i.e. EmployeeName.
and host my application that time
user1 accesses that property and assign value to that property.
the after that
user2 accesses that property and assign value to that property and user1 get the latest value of user2 how can I avoid that.

推荐答案

您应该将该值缓存在静态属性中,而不是缓存到 Session 缓存中。有关详细信息,请参阅 MSDN [ ^ ],和/或下一篇文章:在ASP.NET中探索会话 [ ^ ]
You should cache that value not in static property, but into the Session cache. For details see in MSDN[^], and/or the next article: Exploring Session in ASP.NET[^]


这篇关于想知道静态可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆