Let’s say I have a list of categories for navigation on a web app. Rather than selecting from the database for every user, should I add a function call in the application_onStart of the global.asax to fetch that data into an array or collection that is re-used over and over. If my data does not change at all – (Edit – very often), would this be the best way?
Share
You can store the list items in the Application object. You are right about the
application_onStart(), simply call a method that will read your database and load the data to the Application object.In Global.asax
Now you can access your list in the rest of the project. For example, in default.aspx to load the values in a DropDownList:
And in the code-behind file: