There are 2 things you can use to store global variables (object of class):
1. Application state
2. Cache
The data/object stored in any of above are available for every user & any page of the application.. if data stored is critical and you want it all the time then you can use Application state while if data stored is big and if you want to allow your application to get rid of that data after some time or if memory resources are scarce then you can use Cache..
Here is sample use of Application state
/* To store any value in Application */
Application("PageRequestCo
/* To retrieve value from Applicatoin state */
If (Not Application("PageRequestCo
Dim pageRequestCount As Int = Application("PageRequestCo
End If
To read more on Application state:
http://quickstart.develope
Caching can be done very similar way check this tutorial out for that:
http://quickstart.develope
It's always a good idea to use one static class in your project to store/retrieve values from cache/application state.. it will allow you to change the method of storing retrieving value in one place if you decide to change the mechanism anytime..
-tushar
Main Topics
Browse All Topics





by: nisarkhanPosted on 2007-11-03 at 15:32:18ID: 20208330
based on what i understood.
you can put your variable in global.asax page in the application_onstart
private const string global_variable = "something"
hth