What's the best way to manage a global variable in asp.net?
4 answers
Usually this type requires a Singleton . However, I would recommend to never code a single single yourself and use the Injection / IoC Dependency framework to handle the service lifecycle.
Another thing you have to remember with ASP.NET is that the ASP.NET process will automatically recycle itself every time and then, so you will need to save the changes to the permenant store (like filesystem or database)
+2
source to share
As an alternative to application state, consider simply making your variable static. It will basically mean the same thing, with the added benefit of being strongly typed.
Personally, I would go with what David suggested and use a single core service that is managed by an IoC container.
0
source to share