0

Possible Duplicate:
ASP.NET Application state vs a Static object

I am using the static variable to share the data between all the users. But we have also application object, with help of the application , we can also share data between all user. Can any explain, where can we use static variable and the application object.

Community
  • 1
  • 1
Kumar Manish
  • 3,746
  • 3
  • 37
  • 42

1 Answers1

2

Any of the Application object\static object approach would fail in a multi server scenario. If your state sharing is more of a read only view of some data things may work, but in a read-write scenario things would fail. In such a scenario you need delegate state storage to another machine altogether (such as state server, sql server, memcache etc).
If you compare static and application object i would strongly suggest you to go with Application object as it has some thread synchronization built into it, which can help avoid inconsistent data retrieval.

Chandermani
  • 42,589
  • 12
  • 85
  • 88